Rename-Item registry key from pipeline adds a space -
i'm learning powershell should simple of you...
i have followinng command rename multiple registry subkeys:
get-childitem -path hklm:\software\sccminv\officeaddins\addins -name -recurse | % { rename-item $_ "hklm_ $_" }
the problem new key name results in space between string text , pipeline input, such as:
"hklm_(space)search.outlooktoolbar"
any suggestions?
your code, posted, include space between 'hlkm_' , '$_'
{ rename-item $_ "hklm_ $_" }
if typo, use following code, trims spaces $_ prior inserting string replace {0} token.
{ rename-item $_ ( "hklm_{0}" -f $_.trim() ) }
Comments
Post a Comment