https://www.powershellgallery.com/

$psitem

In powershell, code block(an AST) can be passed as an argument.

operator

-not: logic not

-or: logic or

-and: logic and


-lt: string and number less than

-gt: string and number greater than

-eq: string and number equal

-ne: string and number not equal

-ge: string and number greater equal

-le: string and number less than

These operators are case-insensitive when used with strings. This means that the results will be the same whether the letters are capitalized or not. A case-sensitive version of each operator is available and begins with the letter c, such as -ceq and -cne.

PowerShell also contains the -like operator and its case-sensitive companion, -clike. The -like operator resembles -eq but supports the use of the question mark (?) and asterisk (*) wildcard characters in string comparisons.

Other, more advanced operators exist that are beyond the scope of this course. These operators include:

  • The -in and -contains operators, which test whether an object exists in a collection.
  • The -as operator, which tests whether an object is of a specified type.
  • The -match and -cmatch operators, which compare a string to a regular expression. PowerShell also contains many operators that reverse the logic of the comparison, such as -notlike and -notin.

Help

get-command

get-module

get-verb

get-help

show-command

Know an object

get-member

get-member -inputobject $object

select-object 属性名:

can get a dict with name and expression as its keys to dynamically generate properties.

format

format-list

none

format-table:

  • -AutoSize. This parameter adjusts the size and number of columns based on the width of the data. In Windows PowerShell 5.0 and newer, -AutoSize is set to true by default. In older versions of Windows PowerShell, the default values might truncate data in the table.
  • -HideTableHeaders. This parameter removes the table headers from the output.
  • -Wrap. This parameter causes text that's wider than the column width to wrap to the next line.

format-wide:

-groupby

Type

Array

元素一,元素二,元素三

Dict

@{
键一=值一;
键二=值二;
}

Statistic

sort-object

measure-object

Misc

$variable = command

"Hi, I'm $name"

Array

$a = @()

[array]$b = "array"

$c = "element1","element2","element3"

$vector = New-Object System.Collections.ArrayList

$vector.remove()

$vector.removeat()

$vector.add()

dict

$dict = @{"Key1" = "Value1"; "Key2" = "Value2"}

enumerate

foreach-object:

-process

output

out-file 文件名

out-printer

out-gridview

out-host

send-mailmessage

convertto-*

  • can be clixml csv json html

exportto-* 文件名

  • can be csv clixml

CmdLet

DISM

Dism.exe command DISM cmdlet
Dism.exe /Append-Image Add-WindowsImage
Dism.exe /Apply-Image Expand-WindowsImage
Dism.exe /Capture-Image New-WindowsImage
Dism.exe /Cleanup-MountPoints Clear-WindowsCorruptMountPoint
Dism.exe /Commit-Image Save-WindowsImage
Dism.exe /Export-Image Export-WindowsImage
Dism.exe /Get-ImageInfo Get-WindowsImage
Dism.exe /Get-MountedImageInfo Get-WindowsImage -Mounted
Dism.exe /Get-WimBootEntry Get-WIMBootEntry
Dism.exe /List-Image Get-WindowsImageContent
Dism.exe /Mount-Image Mount-WindowsImage
Dism.exe /Split-Image Split-WindowsImage
Dism.exe /Remove-Image Remove-WindowsImage
Dism.exe /Remount-Image Mount-WindowsImage -Remount
Dism.exe /Unmount-Image Dismount-WindowsImage
Dism.exe /Update-WimBootEntry Update-WIMBootEntry
Dism.exe /Image:<…> /Add-Driver Add-WindowsDriver
Dism.exe /Image:<...> /Add-Package Add-WindowsPackage
Dism.exe /Image:<...> /Add-ProvisionedAppxPackage Add-AppxProvisionedPackage
Dism.exe /Image:<...> /Apply-Unattend Apply-WindowsUnattend
Dism.exe /Image:<...> /Cleanup-Image /CheckHealth Repair-WindowsImage -CheckHealth
Dism.exe /Image:<...> /Cleanup-Image /ScanHealth Repair-WindowsImage –ScanHealth
Dism.exe /Image:<...> /Cleanup-Image /RestoreHealth Repair-WindowsImage –RestoreHealth
Dism.exe /Image:<...> /Disable-Feature Disable-WindowsOptionalFeature
Dism.exe /Image:<...> /Enable-Feature Enable-WindowsOptionalFeature
Dism.exe /Image:<...> /Export-Driver Export-WindowsDriver
Dism.exe /Image:<...> /Get-CurrentEdition Get-WindowsEdition -Current
Dism.exe /Image:<...> /Get-Driverinfo Get-WindowsDriver -Driver
Dism.exe /Image:<...> /Get-Drivers Get-WindowsDriver
Dism.exe /Image:<...> /Get-Featureinfo Get-WindowsOptionalFeature -FeatureName
Dism.exe /Image:<...> /Get-Features Get-WindowsOptionalFeature
Dism.exe /Image:<...> /Get-Packageinfo Get-WindowsPackage -PackagePath
Dism.exe /Image:<...> /Get-Packages Get-WindowsPackage
Dism.exe /Image:<...> /Get-ProvisionedAppxPackages Get-AppxProvisionedPackage
Dism.exe /Image:<...> /Get-TargetEditions Get-WindowsEdition -Target
Dism.exe /Image:<...> /Optimize-Image Optimize-WindowsImage
Dism.exe /Image:<...> /Remove-Driver Remove-WindowsDriver
Dism.exe /Image:<...> /Remove-Package Remove-WindowsPackage
Dism.exe /Image:<...> /Remove-ProvisionedAppxPackage Remove-AppxProvisionedPackage
Dism.exe /Image:<...> /Set-Edition Set-WindowsEdition
Dism.exe /Image:<...> /Set-ProductKey Set-WindowsProductKey
Dism.exe /Image:<...> /Set-ProvisionedAppxDataFile Set-AppXProvisionedDataFile