Skip to content

Instantly share code, notes, and snippets.

@ploegert
Created June 9, 2015 14:30
Show Gist options
  • Select an option

  • Save ploegert/e11a34b22866aa2ecd93 to your computer and use it in GitHub Desktop.

Select an option

Save ploegert/e11a34b22866aa2ecd93 to your computer and use it in GitHub Desktop.
Install PowershelL remoting Enables PowerShell remoting
#
# 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