Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
- $myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
- $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
- if (-not $myWindowsPrincipal.IsInRole($adminRole))
- {
- $newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
- $newProcess.Arguments = $myInvocation.MyCommand.Definition;
- $newProcess.Verb = "runas";
- [System.Diagnostics.Process]::Start($newProcess);
- exit
- }
- New-Item C:\Windows\Temp\nagios
- ## Server 2008 Compatibility, hence .Net.
- "Downloading NSClient"
- $downloader = new-object System.Net.WebClient
- $downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
- $downloader.DownloadFile('http://<P-Address>/nsclient.ini.txt','C:\Windows\Temp\nagios\nsclient.ini')
- If ($ENV:PROCESSOR_ARCHITECTURE -eq 'x86') {
- $downloader.DownloadFile('http://<IP-Address>/NSCP-0.4.3.143-Win32.msi','C:\Windows\Temp\nagios\NSCP-0.4.3.143-Win32.msi')
- Start-Process -FilePath msiexec -ArgumentList /i, C:\Windows\Temp\nagios\NSCP-0.4.3.143-Win32.msi, /passive, /norestart, ADDLOCAL='ALL', REMOVE='Documentation,NSCAPlugin' -Wait
- }
- Else {
- $downloader.DownloadFile('http://<IP-Address>/NSCP-0.4.1.105-x64.msi','C:\Windows\Temp\nagios\NSCP-0.4.1.105-x64.msi')
- Start-Process -FilePath msiexec -ArgumentList /i, C:\Windows\Temp\nagios\NSCP-0.4.1.105-x64.msi, /passive, /norestart, ADDLOCAL='ALL', REMOVE='Documentation,NSCAPlugin' -Wait
- }
- Copy-Item -Path 'C:\Windows\Temp\nagios\nsclient.ini' -Destination 'C:\Program Files\NSClient++\nsclient.ini' -Force
- Restart-Service nscp
- Remote-Item C:\Windows\Temp\nagios -Recurse -Force
Advertisement
Add Comment
Please, Sign In to add comment