Question

The below array containing a lengthy a command line and I have to execute the same This is the command for verifying SCCM .MIG file using USMTUTIL.EXE

$array = "C:\MININT\amd64\usmtutils /verify:All \\SMB001.India.kerala.net\SMPSTORED_91DAA93F$\2AE09BF0AADC04FC89E0CE8A49E8C904E44C0314A123824A7EB289CAFC258026\USMT\USMT.mig /Decrypt /key:PZSTqMLlsJAYna/ndimPT1SrSAz4JjSNH1P7Sv/8mDj8qmytPcLPE3lYzxHnMiVj/6UkdDcWmiaKqgxHO3yjZj2gu8r/j23oefWOsdyWbo4r3UX2gPvMO38np7OOabZ8B0B6A5mAYynAjfy/1e00uhIm1h6soFUWIuu3wkNevBHxkWQs4xslGlooVOn0f+1kGqe05iRWUaVZC4/yYKv3LdbFLhzRXOxVYjriao4oKCEpNEdjnDK6DRoRRrbDy8Ac > C:\temp\DENDMNPWTST008.log"

I tried Invoke-expression $array

While executing this command, Its separating into different lines and only first line is executing and showing error. But I can copy-paste and run it

Error: CategoryInfo : NotSpecified: (:String) [], RemoteException FullyQualifiedErrorId : NativeCommandError 
Was it helpful?

Solution

Invoke-Expression is expecting a string argument and not a string array.

try this:

Invoke-Expression ($array | out-string)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top