PowerShell

From Help
Jump to: navigation, search

Return to Main Page

Setting up a profile

To be able to have your PowerShell automatically open up with pre-set items like colors, execution polices, aliases, etc you need to set up your Powershell user profile.

  • Test to see if you even have a user profile implemented:
    • test-path $profile
    • If this returns false:
      • New-Item -path $profile -type file -force
    • You will see the directory and name from above, open this file up in NotePad++
    • Input whatever items you want this profile to run with in this file and save it

Now every time you run PowerShell, it will automatically load these settings for you.

Return to Top

Potential profile settings

  • Colors: you can change both foreground and background colors

[console]::BackgroundColor = "color you want"

[console]::ForegroundColor = = "color you want"

  • I put the lighter colors on a black background to make them readable
Color Color Color Color
White Black Gray DarkGray
Blue DarkBlue Magenta DarkMagenta
Cyan DarkCyan Red DarkRed
Yellow DarkYellow Green DarkGreen
  • Change the name of the window:

$Host.UI.RawUI.WindowTitle = "Window Name Here"

  • Change default execution policy: (this needs to be in the order below or you'll get an error)

Set-ExecutionPolicy unrestricted

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force

Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Bypass -Force

  • Change default shell location:

set-location c:\

Return to Top

Enabling Remote Powershell

  • Computer Configuration > Policies > Windows Components > Windows Remote Management (WinRM) > WinRM Service.
    • “Allow automatic configuration of listeners”: *
  • Computer Configuration > Preferences > Control Panel Settings > Services
    • WinRM, Start Service, AutoDelated, Account: LocalSystem, Interactive: Yes, Recovery Yes
  • For better security:
  • Computer Configuration > Administrative Templates > Windows Components > Windows Remote Management (WinRM) > WinRM Client
    • Allow Basic authentication: Disabled
    • Allow unencrypted traffic: disabled
  • Computer Configuration > Administrative Templates > Windows Components > Windows Remote Management (WinRM) > WinRM Server
    • Allow remote server management through WinRM: Enabled
    • Allow Basic authentication: Disabled
    • Allow unencrypted traffic: disabled
  • Computer Configuration > Administrative Templates > Windows Components >Windows Remote Shell
    • Allow Remote Shell Access: Enabled
  • On the target server, start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator.

At the PowerShell prompt, you can verify that the WinRM service is running using the following command:

get-service winrm -computer TESTPCNAME

The value of the Status property in the output should be “Running”.

  • To configure Windows PowerShell for remoting, type the following command:

Enable-PSRemoting –force

Return to Top