Reputation: 3
I'm just learning Powershell so this should be simple for some of you...
I have the followinng command to rename multiple registry subkeys:
Get-Childitem -Path HKLM:\SOFTWARE\SCCMINV\OfficeAddins\Addins -Name -Recurse | % { rename-item $_ "HKLM_ $_" }
The problem is that the new key name results in a space between the string text and pipeline input, such as:
"HKLM_(space)Search.OutlookToolbar"
Any suggestions?
Upvotes: 0
Views: 271
Reputation: 2772
Your code, as posted, DOES include a space between 'HLKM_' and '$_'
{ rename-item $_ "HKLM_ $_" }
If this IS just a typo, you could use the following code, which trims any spaces from $_
prior to inserting it into the string to replace the {0}
token.
{ rename-item $_ ( "HKLM_{0}" -f $_.Trim() ) }
Upvotes: 0