PowerShell

Get MD5 of a file

Get-FileHash -Path [file path] -Algorithm MD5

## the value of MD5 depends on the file content

Get installed SQL server version

Invoke-Sqlcmd -Query "SELECT @@VERSION;" -QueryTimeout 3

Get processor info

Get-WmiObject –class Win32_processor | select *

Get IP address information and sort the output

Get-NetIPAddress | Sort-Object -Property InterfaceIndex | Format-Table

Verify if an IP address exists

Get-NetIPAddress -IPAddress [ip_address]

## if found, returns the details
## else, throws error

Export certificate to SST type

Get-ChildItem -Path cert:\localmachine\root | Export-Certificate -FilePath c:\certs\allcerts.sst -Type SST

## if get error: Export-Certificate : The object or property already exists.
## it means there is duplicate object in the Get-ChildItem pipeline, Select-Unique to solve this

Import certificate

Import-Certificate -FilePath "{cert_file_path}" -CertStoreLocation cert:\localmachine\root
创建时间:6/25/2022 8:45:30 PM 修改时间:6/25/2022 8:49:35 PM