I have a some code in PowerShell and I need to use it in cmd.exe
I am using this command in cmd.exe
powershell -command "command"
But it gives me this error
At line:1 char:72
+ ... nt D:\15.txt -TotalCount 3)[-1] | Foreach-object {$_ -replace REG_SZ, ...
+ ~
You must provide a value expression following the '-replace' operator.
At line:1 char:73
+ ... 5.txt -TotalCount 3)[-1] | Foreach-object {$_ -replace REG_SZ, } | F ...
+ ~~~~~~
Unexpected token 'REG_SZ' in expression or statement.
At line:1 char:79
+ ... .txt -TotalCount 3)[-1] | Foreach-object {$_ -replace REG_SZ, } | Fo ...
+ ~
Missing argument in parameter list.
At line:1 char:113
+ ... -object {$_ -replace REG_SZ, } | Foreach-object {$_ -replace Gmail, ...
+ ~
You must provide a value expression following the '-replace' operator.
At line:1 char:114
+ ... t {$_ -replace REG_SZ, } | Foreach-object {$_ -replace Gmail, } | s ...
+ ~~~~~
Unexpected token 'Gmail' in expression or statement.
At line:1 char:119
+ ... {$_ -replace REG_SZ, } | Foreach-object {$_ -replace Gmail, } | se ...
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
My command is :
powershell -command "(Get-Content D:\15.txt -TotalCount 3)[-1] | Foreach-object {$_ -replace "REG_SZ", " "} | Foreach-object {$_ -replace "Gmail", " "} | set-content D:\15.txt"