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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -