Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- #$ErrorActionPreference = "silentlycontinue"
- $Logfile = "C:tempNEWnetbackup_version.log"
- Function LogWrite
- {
- param([string]$logstring)
- Add-Content $Logfile -Value $logstring
- }
- $computer = Get-Content -Path c:tempnetbackup_servers1.txt
- foreach ($computer1 in $computer){
- $Service = Get-WmiObject Win32_Service -Filter "Name = 'NetBackup Client Service'" -ComputerName $computer1
- if (test-connection $computer1 -quiet)
- {
- $NetbackupVersion1 = $(Get-ItemProperty hklm:SOFTWAREVeritasNetBackupCurrentVersion).PackageVersion
- if($Service.state -eq 'Running')
- {
- LogWrite "$computer1 STARTED $NetbackupVersion1"
- }
- else
- {
- LogWrite "$computer1 STOPPED $NetbackupVersion1"
- }
- }
- else
- {
- LogWrite "$computer1 is down" -foregroundcolor RED
- }
- }
- $Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
- $RegKey= $Reg.OpenSubKey("SOFTWARE\Veritas\NetBackup\CurrentVersion")
- $NetbackupVersion1 = $RegKey.GetValue("PackageVersion")
- Import-Module PSRemoteRegistry
- Get-RegValue -ComputerName $Computer1 -Key SOFTWAREVeritasNetBackupCurrentVersion -Value PackageVersion
- $Session = New-PSSession -ComputerName $Computer1 -Authentication CredSSP
- $NetbackupVersion1 = Invoke-Command -Session $Session -ScriptBlock { $(Get-ItemProperty hklm:SOFTWAREVeritasNetBackupCurrentVersion).PackageVersion}
- Remove-PSSession $Session
- $w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$computer1)
- $keypath = 'SOFTWAREVeritasNetBackupCurrentVersion'
- $netbackup = $w32reg.OpenSubKey($keypath)
- $NetbackupVersion1 = $netbackup.GetValue('PackageVersion')
- <# Replace following domain.name with yours and userAccountName with remote username #>
- $userLogin = New-Object System.Security.Principal.NTAccount(“domain.name“,”userAccountName“)
- $userSID = $userLogin.Translate([System.Security.Principal.SecurityIdentifier])
- <# We will open HKEY_USERS and with accurate user’s SID from remoteComputer #>
- $remoteRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘Users’,”remoteComputer“)
- <# We will then retrieve LocalName value from Control Panel / International subkeys #>
- $key = $userSID.value+”Control PanelInternational”
- $openKey = $remoteRegistry.OpenSubKey($key)
- <# We can now retrieve any values #>
- $localName = $openKey.GetValue(‘LocaleName’)
- import wmi
- conn = wmi.WMI('172.20.58.34', user='UserName', password='Password')
- command = r'cmd /c reg query "HKLMSOFTWAREMicrosoft" /ve > C:output.txt'
- conn.Win32_Process.Create(CommandLine=command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement