Change Code Page: chcp 437
Refresh Group Policy three times and wait for five minutes between refreshes:
1..3 | % {gpupdate ; sleep 300}
The conceptual Help topics: Get-Help About_
Get-Help
, Get-Command
, Get-Member
, Show-Command
-ErrorAction:
SilentlyContinue, Stop, Continue, Inquire, Ignore
Start-Transcript Stop-Transcript
Test file exists: Test-Path $PROFILE
Create windows powershell profile: New-Item $profile -ItemType file -Force
Get-Process
= gps
Formatting: Format-Table ft
, Format-List fl
, Format-Wide fw
Out-GridView
= ogv
Exporting Data: Out-File
, Export-CSV
, Export-Clixml
creates a new alias named Processes for the Get-Process cmdlet:
PS C:\> Set-Location alias:
PS Alias:\> New-Item -Name Processes -Value Get-Process
or
New-Alias -Name myservice -Value Get-Service
Name Use
$ Contains the first token of the last line input into the shell.
$$ Contains the last token of the last line input into the shell.
$_ The current pipeline object; used in script blocks, filters, Where-Object, ForEach-
Object, and Switch.
$? Contains the success or fail status of the last statement.
$Args Used in creating functions requiring parameters.
$Error If an error occurs, the error object is saved in the $error variable.
$ExecutionContext The execution objects available to cmdlets.
$foreach Refers to the enumerator in a ForEach loop.
$HOME The user’s home directory; set to %HOMEDRIVE%\%HOMEPATH%.
$Input Input is piped to a function or code block.
$Match A hash table consisting of items found by the -match operator.
$MyInvocation Information about the currently executing script or command line.
$PSHome The directory where Windows PowerShell is installed.
$Host Information about the currently executing host.
$LastExitCode The exit code of the last native application to run.
$true Boolean true.
$false Boolean false.
$null A null object.
$this In the Types.ps1xml file and some script block instances, this represents the current
object.
$OFS Output Field Separator used when converting an array to a string.
$ShellID Identifier for the shell. This value is used by the shell to determine the
ExecutionPolicy and which profiles are run on startup.
$StackTrace Contains detailed stack trace information about the last error.