Powershell – essential tidbits

One of the killer features of powershell is to remotely manage machines. The ability to actually manage a remote machine is not enabled out of the box. It requires poking holes in the firewall and adding a few key plugins. Here are two commands I run on every machine.

The following allows you to execute .ps1 files. I think it’s ridiculous this is not enabled by default. Windows allows you to run .bat files out of the box. .ps1’s are .bat files that don’t suck.

Set-ExecutionPolicy RemoteSigned

This tidbit sets up the machine to be connected to via PowerShell remote commands.

winrm quickconfig
winrm s winrm/config/client '@{TrustedHosts="*"}'
winrm s winrm/config/Winrs '@{MaxMemoryPerShellMB = "1000"}'

Note: Make sure you run PowerShell as an Administrator or you will get the following error:

Message = Access is denied.

Error number: -2147024891 0x80070005
Access is denied.

Assuming Windows Permissions are setup you can now connect with Enter-PSSession and Exit-PSSession.

This entry was posted in .Net and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s