12 February 2015

ISE script debugging


F9   - set line breakpoint - the script will pause when the designated line must be executed

F10 - step over - executes the current statement and then stop at the next statement. If the current statements is a function or script call then the debugger executes the whole function or script, and it stops at the next statement.

F11 - step into - executes the current statement and then stops at the next statement. If the current statement is a function or script call, then the debugger steps into that function or script.

SHIFT + F11 - step out - steps out of the current function and up one level if the function is nested. If in the main body, the script is executed to the end, or to the next breakpoint.

F5 - continue - continues execution to the end, or to the next breakpoint.

09 February 2015

Motherboard model and manufacturer

Get-CimInstance Win32_BaseBoard | Select-Object Manufacturer, Product

Get-WmiObject Win32_BaseBoard | Select-Object Manufacturer, Product


Use wmic:

wmic baseboard get product, manufacturer

26 January 2015

Active Directory schema attribute details

$schema =[DirectoryServices.ActiveDirectory.ActiveDirectorySchema]::GetCurrentSchema()

$schema.FindClass('user').optionalproperties | Where-Object {$_.name -eq 'employeeid'}

11 January 2015

Scheduled jobs in powershell v3

PSScheduledJob is the module name.

Scheduled jobs can be viewed in Task Scheduler GUI.

Scheduled jobs cmdlet can only be used for the path: Microsoft\Windows\PowerShell\ScheduledJobs

SheduledTask module can be used to manage all other scheduled tasks (available only in Windows 8 and Server 2012).

Job definition and output is stored on disk in different files that can be found on:

%UserProfile%\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\JobName

09 January 2015

About modules in powershell v3

Powershell have two default location in which it search for modules: one for the system and one for the user currently logged on:

  • system: %windir%\System32\WindowsPowerShell\v1.0\Modules
  • user: %UserProfile%\Documents\WindowsPowerShell\Modules
these values are stored in a environment variable $ENV:PSModulePath

Modules from this location will be automatically imported in powershell v3.

Get-Command cmdlet will return commands from imported or modules available in the two paths.

In powershell v3, modules can be imported (or listed) from another computer trough a cimsession or powershell session:

Import-Module -CimSession $session -Name ModuleName

Get-Module -CimSession $session -ListAvailable