I am trying to get two value data in one line. It works fine when I do it in two line but I want to use one line code. Any help would be appreciated.
Here is my code:
Blockquote
$Getservice = Get-Service -ComputerName $Computer -Name RemoteRegistry
If ($Getservice.Status -eq "Stopped") {
Set-service -ComputerName $Computer -Name RemoteRegistry -Status Running -StartupType Manual -ErrorAction stop
$regcon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $Computer)
$regkey = $regcon.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\")
$gvalue = $regkey.GetValue('DisplayVersion')
$winver = $regkey.GetValue('ReleaseID')
}
Do {
Get-service -ComputerName $Computer -Name RemoteRegistry | Stop-Service -Force
Set-Service -ComputerName $Computer -Name RemoteRegistry -Status Stopped -StartupType Disabled
$StopRemoteRegistry = Get-Service -ComputerName $Computer -Name RemoteRegistry
} while($StopRemoteRegistry.StartType -eq "Enabled")
Blockquote
I am trying to accomplish...
$winver = $regkey.GetValue('ReleaseID', 'DisplayVersion')