考虑:
$ProfilePath = "HKLM:\software\microsoft\windows NT\currentversion\profilelist"
$ProfileList = ls -path $ProfilePath
foreach ($guid in $ProfileList)
{
$gpath = $guid -replace "HKEY_LOCAL_MACHINE","HKLM:"
$userpath = Get-ItemProperty -path "$gpath" | select ProfileImagePath
$SUserName = [system.string]::$userpath
$username = $userpath -replace "ProfileImagePath=C:\\Users\\",""
}
目前$userpath = @{ProfileImagePath=C:\Windows\ServiceProfiles\NetworkService
. 我需要把它变成一个字符串,以便进行比较。我怎样才能让它转换为字符串?
我尝试$SUserName
生成 ablank
或null string
.