Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Created April 7, 2021 15:35
Show Gist options
  • Save steviecoaster/56ea6a358947c59996ba24778e773400 to your computer and use it in GitHub Desktop.
Save steviecoaster/56ea6a358947c59996ba24778e773400 to your computer and use it in GitHub Desktop.
Quickly setup PSRemoting on Non-domain bound endpoints
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[String[]]
$TrustedHosts
)
begin {
if(-not (Test-WSMan)){
Enable-PSRemoting -Force
}
}
process {
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
$winrmArgs = @('set','winrm/config/client',"'{TrustedHosts=`"$($TrustedHosts -join ',')`"}'")
& winrm @winrmArgs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment