Created
June 9, 2015 14:30
-
-
Save ploegert/e11a34b22866aa2ecd93 to your computer and use it in GitHub Desktop.
Install PowershelL remoting Enables PowerShell remoting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Enables PowerShell remoting | |
| # | |
| function Enable-Remoting | |
| { | |
| [CmdletBinding()] | |
| param() | |
| Write-Log 'Enabling PowerShell Remoting...' | |
| # | |
| # Vista and above Standalone machines need to be setup as private network | |
| # | |
| if ([environment]::OSVersion.version.Major -ge 6) | |
| { | |
| # | |
| # Win32_ComputerSystem.DomainRole can have the following values (http://msdn.microsoft.com/en-us/library/aa394102(v=vs.85).aspx): | |
| # | |
| # 0 - Standalone Workstation | |
| # 1 - Member Workstation | |
| # 2 - Standalone Server | |
| # 3 - Member Server | |
| # 4 - Backup Domain Controller | |
| # 5 - Primary Domain Controller | |
| # | |
| if (@(0, 2) -contains (Get-WmiObject Win32_ComputerSystem).DomainRole) | |
| { | |
| Write-Log 'Setting up network connections as private' | |
| # Get network connections | |
| $networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')) | |
| $connections = $networkListManager.GetNetworkConnections() | |
| # Set network location to Private for all networks | |
| $connections | % { $_.GetNetwork().SetCategory(1) } | |
| } | |
| } | |
| # discard output; disable strict mode | |
| & { | |
| Set-StrictMode -Off | |
| Enable-PSRemoting -Force > $null | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment