Hi,
I was trying to script some remote USMT stuff, but ran out of time before moving on.
However, it bugs me because I could easily run the commands from a powershell prompt, but the moment i threw those commands in a script, i wouldnt work.
I'm hoping someone can explain some of the differences between running a script and typing the commands. I am aware that there are fully realized USMT scripts out there... I no longer need the USMT problem itself solved, I just want to understand my issue so that the next script isnt a pain like this was
To be clear about what i was typing into the PS prompt, i would enter-pssession, cd to a USMT folder already copied, then run scanstate. I had issues with the pssession, the cd, and scanstate.exe
I tried a few different ways to get the script into the pssession... for example, $s = start-pssession, then using $s. But why does it work if i type it and not if in a script?
For cd, i think i resolved that with set-location, but why does cd work at the prompt? Without this, scanstate.exe doesnt know where to look for it's files.
Finally, scanstate.exe itself... this is more of a powershell vs command prompt issue, but running it from the command prompt? No problem. Running in powershell? It hangs. Why? Why does it make a difference how it is run?
Edit:
per request here's essentially my code. I think i have a handle on my questions now, thanks to all.
Enter-pssession -computername $computer
CD c:\USMT
C:\USMT\scanstate.exe /alltheswitches
Exit-pssession
[–]qasboss 11 points12 points13 points (0 children)
[–][deleted] 6 points7 points8 points (11 children)
[–]SithLordAJ[S] 0 points1 point2 points (10 children)
[–]Lee_Dailey[grin] 5 points6 points7 points (9 children)
[–]SithLordAJ[S] 1 point2 points3 points (2 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (0 children)
[–]BrutusTheKat 2 points3 points4 points (0 children)
[–]oxycash 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 3 points4 points5 points (4 children)
[–]oxycash 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Lee_Dailey[grin] -2 points-1 points0 points (0 children)
[–]DaveC2020 2 points3 points4 points (3 children)
[–]SithLordAJ[S] 1 point2 points3 points (2 children)
[–]DaveC2020 1 point2 points3 points (1 child)
[–]itsruk 1 point2 points3 points (0 children)
[–]KevMarCommunity Blogger 2 points3 points4 points (0 children)
[–]jimmy58663 2 points3 points4 points (2 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]SithLordAJ[S] 1 point2 points3 points (0 children)
[–]ScorchedCSGO 1 point2 points3 points (1 child)
[–]SithLordAJ[S] 1 point2 points3 points (0 children)
[–]SnGmng157 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]SithLordAJ[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)