Archive

Posts Tagged ‘Powershell’

Powershell cheatsheet for C++/C#

June 22nd, 2016 Comments off

This is just a small post to help my ageing memory remember where things are located.

  • Powershell C#
    Locate the dll, System.Management.Automation.dll, and add it to your project, (or add it via Nuget).

    • See this blog for a good introduction on creating a project, (works for vs2015).
  • Check what version is installed
    • According to the official site you need to check the registry
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1
      or
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3
      And check that the value Install is set to ‘1’.
  • Debuging
    • The external program is C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    • But the actual location is:
      • Powershell 1: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine\{ApplicationBase}
      • Powershell 3:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine\{ApplicationBase}
    • Launching from debuger:
      • For a script:
        PowerShell -Command “& {.\myscript.ps1}” or
        PowerShell -File “.\myscript.ps1”
      • For a CmdLet/Module:
        -noexit -command “&{ import-module .\AMPowerShellCmdLets.dll -Verbose}”
  • Some links
Categories: development Tags: , ,