You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.1 KiB
Markdown

# PS Commands
Note: unless otherwise stated, replace any variable such as `$ComputerName` with the appropriate data.
<br>
## Computers
<br>
### Remotely Fetch a (Partial) Installed Program List for $ComputerName
```powershell
Get-WmiObject win32_product -ComputerName $ComputerName | Sort-Object | select Vendor, Name, version
```
1 year ago
<br>
### Remotely Fetch Installed Programs from $ComputerName by searching $Column (Vendor, Name, or version) for $SearchTerm
```powershell
Get-WmiObject win32_product -ComputerName $ComputerName | Where-Object {$_.$Column -like “*$SearchTerm*”} | Sort-Object | select Vendor, Name, version
```
<br>
### Remotely Fetch $ComputerName's Boot Time
```powershell
Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName | slect csname, lastbootuptime
```
<br>
### Fetch $ComputerName's Group Membership
```powershell
Get-ADPrincipalGroupMembership (Get-ADComputer $ComputerName) | select-object name
```
<br>
### Remotely Fetch $ComputerName's Make & Model
```powershell
Get-CimInstance -ComputerName $ComputerName -ClassName Win32_ComputerSystem | Select-Object -Property Manufacturer, Model
```
<br>
### Remotely Fetch $ComputerName's Serial Number
```powershell
Get-CimInstance -ComputerName $ComputerName -ClassName Win32_bios | Select-Object -Property SerialNumber
```
<br>
### Remotely Fetch $ComputerName's Total/Free Storage
```powershell
Get-WmiObject Win32_LogicalDisk -ComputerName $ComputerName -Filter DriveType=3 | Select-Object DeviceID, @{'Name'='Size (GB)'; 'Expression'={[math]::truncate($_.size / 1GB)}}, @{'Name'='Freespace (GB)'; 'Expression'={[math]::truncate($_.freespace / 1GB)}}
```
<br>
### Remotely Fetch $ComputerName's BIOS Version
```powershell
Get-WmiObject -Class Win32_BIOS -ComputerName $ComputerName
```
<br>
## Users
<br>
### Fetch $Username's Group Membership
```powershell
Get-ADPrincipalGroupMembership (Get-ADUser $Username) | select-object name
```
<br>
## Groups
<br>
### Fetch AD Groups with $SearchTerm in them
```powershell
Get-ADGroup -Filter 'name -like "*$SearchTerm*"' | Sort-Object | select Name
```
<br>