BlackWOlf23
Vendor
Hi Guys,
I've begun learning powershell and have encountered a problem that I'm trying to solve.
Basically I'm working on developing a script that will find the most recent backup file and then run a check on the integrity of this file using a proprietary command that's run from the cmd prompt.The problem I'm having is when I run the code below I encounter the following error.
cmd.exe : ' C : \ P r o g r a m ' i s n o t r e c o g n i z e d a s a n i n t e r n a l o r e x t e r n a l c o m m a n d ,
At C:\Users\user\Desktop\Scripts\VerifyBackup.ps1:27 char:16
+ CMD.exe <<<< /U /C $cmddir v $Md5Name > C:\Temp\Result.txt
+ CategoryInfo : NotSpecified: (' C : \ P r o g... o m m a n d , :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
o p e r a b l e p r o g r a m o r b a t c h f i l e .
I believe that the problem is that I'm passing variables that contains values to the cmd prompt and these variables need to be surrounded in specific quotes. However,I'm unsure which types of quotes/where to place them.
Any help would be appreciated.
Thanks.
I've begun learning powershell and have encountered a problem that I'm trying to solve.
Basically I'm working on developing a script that will find the most recent backup file and then run a check on the integrity of this file using a proprietary command that's run from the cmd prompt.The problem I'm having is when I run the code below I encounter the following error.
cmd.exe : ' C : \ P r o g r a m ' i s n o t r e c o g n i z e d a s a n i n t e r n a l o r e x t e r n a l c o m m a n d ,
At C:\Users\user\Desktop\Scripts\VerifyBackup.ps1:27 char:16
+ CMD.exe <<<< /U /C $cmddir v $Md5Name > C:\Temp\Result.txt
+ CategoryInfo : NotSpecified: (' C : \ P r o g... o m m a n d , :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
o p e r a b l e p r o g r a m o r b a t c h f i l e .
Code:
$CmdDir = "C:\Program Files (x86)\StorageCraft\ShadowProtect\image.exe"
$File_Location = Get-ChildItem E: | Where {$_.extension -eq '.md5'} | Sort-object {$_.LastWriteTime} -Descending | Select-object -First 1 Fullname
CMD.exe /U /C $cmddir v $File_Location > C:\Temp\Result.txt
I believe that the problem is that I'm passing variables that contains values to the cmd prompt and these variables need to be surrounded in specific quotes. However,I'm unsure which types of quotes/where to place them.
Any help would be appreciated.
Thanks.