Hi guys,
i need to query and compare reg-multi-sz value and path multiple times so i have created a function
#Function for check of Registry Key Value is like parameter
function AuditRegistryKeyValue ($RegKeyPath,$RegKeyName,$RegKeyValue,$Description)
{
$Response=((Get-ItemProperty -Path $RegKeyPath -Name $RegKeyName).$RegKeyName)
If ($Response -like $RegKeyValue)
{
write-host $RegKeyPath
write-host $RegKeyValue
}
Else
{
write-host $RegKeyPath
write-host $RegKeyValue
}
}
The $Response and $RegKeyValue are optical the same - but it always goes in the else loop. Why? If I'm not comparing reg-multi-sz it works. I know that reg-multi-sz contains line breaks.
Example:
$Description = "Network access: Remotely accessible registry paths and sub-paths"
AuditRegistryKeyValue -RegKeyPath "hklm:System\CurrentControlSet\Control\SecurePipeServers\Winreg\AllowedPaths" -RegKeyName Machine -RegKeyValue "System\CurrentControlSet\Control\Print\Printers"+`n+"System\CurrentControlSet\Services\Eventlog
Software\Microsoft\OLAP Server Software\Microsoft\Windows NT\CurrentVersion\Print Software\Microsoft\Windows NT\CurrentVersion\Windows System\CurrentControlSet\Control\ContentIndex System\CurrentControlSet\Control\Terminal Server System\CurrentControlSet\Control\Terminal
Server\UserConfig System\CurrentControlSet\Control\Terminal Server\DefaultUserConfiguration Software\Microsoft\Windows NT\CurrentVersion\Perflib System\CurrentControlSet\Services\SysmonLog" -Description $Description
Any ideas? Thank you and kind regards
Peter