I am trying to make a simple powershell script to copy a file that is uploaded into Immy-bot and save it to a folder in the “Default” user profile. It gets as far to create the folder that is needed, but the file never gets copied to the correct folder.
$file
$path = "C:\Users\Default\AppData\Local\Autodesk\DesktopConnector.Applicat_Url_3jj2w2iynvqiiebej5jo1rt0nhfjfaur\16.4.0.2062"
If(!(test-path -PathType container $path))
{
New-Item -ItemType Directory -Path $path
}
{
copy-Item $file -Destination "C:\Users\Default\AppData\Local\Autodesk\DesktopConnector.Applicat_Url_3jj2w2iynvqiiebej5jo1rt0nhfjfaur\16.4.0.2062"
}
This is the error I receive when running the task.
The Test script did not return any usable output.
String ‘“C:\Windows\Temp\ImmyBot\98bddd95-e9f8-878a-5230-8e1f956994b9\user.config”’ was not recognized as a valid Boolean.
String ‘“\r\n copy-Item $file -Destination "C:\Users\Default\AppData\Local\Autodesk\DesktopConnector.Applicat_Url_3jj2w2iynvqiiebej5jo1rt0nhfjfaur\16.4.0.2062"\r\n”’ was not recognized as a valid Boolean.
Please ensure you output at least one $true or $false value to indicate compliance
Given that it seems to be an issue regarding a path returning a boolean, I would look into your test-path line. That being said, I would recommend looking into the ImmyBot custom functions for this. For example, you could create a task with a parameter called file (becomes useable as $file). Then make a combined script 9as a metascript) that goes something like:
$DestinationPath = "C:\Users\Default\AppData\Local\Autodesk\DesktopConnector.Applicat_Url_3jj2w2iynvqiiebej5jo1rt0nhfjfaur\16.4.0.2062"
$File | FileShould-Be -InPath $Destination
However, a quick little tip, the File in Specific Location task in global does exactly this. There is a selection parameter for the path that you can set to other, and then specify any path you want. This will also help you take care of things that may cause issues like permission limitations on the folder.
I ended up using a task from the global library " [Copy Files over LAN]"
It does almost what I want it to do. The only issue is the target computer needs to be connected to the network so it can see the source path of the file.
I’ll keep plugging away at it. I will try the Metascript option and see if it works better.
Thanks.