Show CMD window on target computer
I'm having an issue with a command step in Deploy, the command runs fine on the target computer when done manually, but not using a command step via Deploy.
So trying to make the command window visible on the target computer when it runs the step - using deploy user (interactive) doesn't work.
Any ideas please?
Thanks
1
Comments
What is the command that you're trying to run?
Thanks for replying, I have just opened a case for this...
The command is:
for /f "tokens=2" %u in ('query session ^| findstr /R "^>"') do move c:\users\%u\downloads\filename.txt "C:\Program Files (x86)\Sophos\Sophos SSL VPN Client\config\new_filename.ovpn"
The error is '\users\ufilename.txt was unexpected at this time'
Similar issue with powershell
If using a powershell step I get the error:
You cannot call a method on a null-valued expression.
At C:\Windows\AdminArsenal\PDQDeployRunner\service-1\exec\vpnconfig.ps1:1 char:19
it doesn't like the variable, but the same works fine if run manually on the target machine using the same creds as pdq deploy user
Deploy executes Command steps as a batch file, so variables need 2 % symbols: https://ss64.com/nt/for.html
I would need to see your PowerShell code to diagnose it.
yeah I tried with 2 % symbols, but will try that again.
poweshell is:
$CurrentUser = & {(get-wmiobject Win32_ComputerSystem).UserName.Split('\')[1]}
Move-Item "c:\users\$CurrentUser\downloads\filename.txt" -Destination "C:\Program Files (x86)\Sophos\Sophos SSL VPN Client\config\new_filename.ovpn"
Error is 'You cannot call a method on a null-valued expression.
I'm not sure what it doesn't like about the first line of your PowerShell script. The & is unnecessary, but works fine when I tested it. However, it can be simplified to just 1 line:
Thanks
USERPROFILE is producing the deploy username rather than the logged on user so the path to file is not found
Oh! I misunderstood what the first line was trying to do.
I tried tweaking your script again. If this throws "Split-Path : Cannot bind argument to parameter 'Path' because it is null.", then I suspect you may be running against a target that doesn't have a user logged in, so UserName is empty.
The target has a logged in user, although when I tested the previous command step again with 2 % symbols and made it show the output is was 0.
I will try the PS.
Thanks again!
yeah I got the "Split-Path : Cannot bind argument to parameter" error, strange. I'm wondering if it's anything to do with it being a remote desktop session I have logged in on the target.
Yep it's down to the logged in user being via RDP, it's working when I test logged in to the console on a VM.
Thanks Colby for your excellent help with this!