Example: marketing

PowerShell Basic Cheat Sheet - Rambling Cookie …

BasicsCmdletCommands built into shell written in .NETF unctionsCommands written in PowerShell languageParameterArgument to a Cmdlet/Function/ScriptAliasShortcut for a Cmdlet or FunctionScriptsText files with .ps1 extensionApplicationsExisting windows programsPipelines |Pass objects Get-process word | Stop-ProcessCtrl+cInterrupt current commandLeft/rightNavigate editing cursorCtrl+left/rightNavigate a word at a timeHome / EndMove to start / end of lineUp/downMove up and down through historyInsertToggles between insert/overwrite modeF7 Command history in a windowTab / Shift-TabCommand line completionScriptsSet-ExecutionPolicy -ExecutionPolicy BypassSet execution policy to allow all scripts."\\c-is-ts-91\c$\scripts\ "Run script in current scope&"\\c-is-ts-91\c$\scripts\ "Run script in script scope.\ script in script scope$profileYour personal profile that runs at launchHelpGet-CommandGet all commandsGet-Command -Module RGHSGet all commands in RGHS moduleGet-Command Get-p*Get all commands starting with get-pGet-help get-processGet help for commandGet-Process | Get-MemberGet members of the object Get-Process| format-list -properties *Get-Process as list with all properties Writing output and reading input"This displays a string"String is written directly to outputWrite-Host "color" -ForegroundColor Red -NoNewLineString with colors, no new line at end$age = Read-host "Please enter your age"Set $ag

Basics Cmdlet Commands built into shell written in .NET Functions Commands written in PowerShell language Parameter Argument to a Cmdlet/Function/Script

Tags:

  Basics, Sheet, Teach, Powershell, Powershell basic cheat sheet

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of PowerShell Basic Cheat Sheet - Rambling Cookie …

1 BasicsCmdletCommands built into shell written in .NETF unctionsCommands written in PowerShell languageParameterArgument to a Cmdlet/Function/ScriptAliasShortcut for a Cmdlet or FunctionScriptsText files with .ps1 extensionApplicationsExisting windows programsPipelines |Pass objects Get-process word | Stop-ProcessCtrl+cInterrupt current commandLeft/rightNavigate editing cursorCtrl+left/rightNavigate a word at a timeHome / EndMove to start / end of lineUp/downMove up and down through historyInsertToggles between insert/overwrite modeF7 Command history in a windowTab / Shift-TabCommand line completionScriptsSet-ExecutionPolicy -ExecutionPolicy BypassSet execution policy to allow all scripts."\\c-is-ts-91\c$\scripts\ "Run script in current scope&"\\c-is-ts-91\c$\scripts\ "Run script in script scope.\ script in script scope$profileYour personal profile that runs at launchHelpGet-CommandGet all commandsGet-Command -Module RGHSGet all commands in RGHS moduleGet-Command Get-p*Get all commands starting with get-pGet-help get-processGet help for commandGet-Process | Get-MemberGet members of the object Get-Process| format-list -properties *Get-Process as list with all properties Writing output and reading input"This displays a string"String is written directly to outputWrite-Host "color" -ForegroundColor Red -NoNewLineString with colors, no new line at end$age = Read-host "Please enter your age"Set $age variable to input from user$pwd = Read-host "Please enter your password" -asSecureStringRead in $pwd as secure stringClear-HostClear consoleAliases for common commandsGcmGet-CommandForeach,%Foreach-O bjectSortSort-ObjectWhere,?

2 Where-ObjectDiff,compareCompare-ObjectDi r, ls, gciGet-ChildItemGiGet-ItemCopy,cp,cpiCop y-ItemMove,mv,miMove-ItemDel,rmRemove-It emRni,renRename-ItemFtFormat-TableFlForm at-ListGcimGet-CimInstanceCat,gc,typeGet -ContentScSet-Contenth,history,ghyGet-Hi storyIhy,rInvoke-HistoryGpGet-ItemProper tySpSet-ItemPropertyPwd,glGet-LocationGm Get-MemberSlsSelect-StringCd,chdir,slSet -LocationCls,clearClear-HostVariables$va r = "string"Assign variable$a,$b = 0 or $a,$b = 'a','b'Assign multiple variables$a,$b = $b,$aFlip variables$var=[int]5 Strongly typed variableArrays, Objects$arr = "a", "b"Array of strings$arr = @()Empty array$arr[5]Sixth array element$arr[ ]Last three array elements$arr[1,4+ ]Elements at index 1,4, 6-9$arr[1] += 200 Add to array item value$z = $arA + $arBTwo arrays into single array[pscustomobject]@{x=1;z=2}Create custom object(Get-Date).DateDate property of objectComments, Escape Characters#CommentComment<#comment#>Multiline Comment"`"test`""Escape char ``tTab`nNew line`Line continueAssignment, Logical, Comparison Operators=,+=,-=,++,--Assign values to variable-and,-or,-not,!

3 Connect expressions / statements-eq, -neEqual, not equal-gt, -geGreater than, greater than or equal-lt, -leLess than, less than or equal-replace Hi -replace H , P -match,-notmatchRegular expression match-like,-notlikeWildcard matching-contains,-notcontainsCheck if value in array-in, -notinReverse of contains, ControlIf(){} Elseif(){ } Else{ }while(){}For($i=0; $i -lt 10; $i++){}Foreach($file in dir C:\){$ } | foreach{$_}Importing, Exporting, ConvertingExport-CliXMLI mport-CliXMLC onvertTo-XMLC onvertTo-HTMLE xport-CSVI mport-CSVC onvertTo-CSVC onvertFrom-CSVC mdletsSet-LocationGet-ContentAdd-Content Set-ContentOut-FileOut-StringCopy-ItemRe move-ItemMove-ItemSet-ItemNew-ItemPowerS hell is a task based command line shell and scripting language. To run it, click Start, type PowerShell , run PowerShell ISE or PowerShell as are written in verb-noun form, and named parameters start with a dash. Example command: dir C:\users\example -recurse -File | ?

4 {$ -gt [datetime]::Today} | Select LastWriteTime,CreationTime,Length,FullNa me | sort LastWriteTime -descending | ft -AutoSizeThis gets all files under C:\users\example, filters by lastwritetime today, only returns lastwritetime, creationtime, length and fullname, sorts by lastwritetime and outputs results in an autosized tableParameters-ConfirmPrompt whether to take action-WhatIfDisplays what command would doPowerShell Basic Cheat Sheet


Related search queries