PowerShell Flashcards
Active Directory Module:
The Active Directory module for Windows PowerShell provides cmdlets to manage and automate Active Directory.
Get-ADUser
Retrieves one or more Active Directory
Code:
Get-ADUser -Identity “Username”
Set-ADUser
Modifies properties of an Active Directory
Code:
Set-ADUser -Identity “Username” -Title “New Title”
New-ADGroup:
Creates a new Active Directory
New-ADGroup -Name “GroupName” -GroupScope Global -Path “OU=Groups,DC=domain,DC=com”
Add-ADGroupMember:
Adds one or more members to an Active Directory
Code:
Add-ADGroupMember -Identity “GroupName” -Members “Username”
Networking Module:
The Networking module provides cmdlets to manage network settings on Windows.
Code:
Get-NetIPAddress -InterfaceAlias “Ethernet”
New-NetIPAddress
Configures a new IP address on a network interface
Code:
New-NetIPAddress -InterfaceAlias “Ethernet” -IPAddress “192.168.1.100” -PrefixLength 24 -DefaultGateway “192.168.1.1”
Set-DnsClientServerAddress:
Configures the DNS server addresses of a network interface
Code:
Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses “8.8.8.8”,”8.8.4.4”
Hyper-V Module:
The Hyper-V module allows you to manage Hyper-V virtual machines
New-VM
Creates a new virtual machine.
Code:
New-VM -Name “VMName” -MemoryStartupBytes 1GB -NewVHDPath “C:\VMs\VMName\disk.vhdx” -NewVHDSizeBytes 20GB -Generation 2
Start-VM
Starts a virtual machine.powershell
Code:
Start-VM -Name “VMName”
Stop-VM
Powers off a virtual machine
Code:
Stop-VM -VM “VMName”
Configuration Manager Module:
The Configuration Manager module for PowerShell is used to automate SCCM/MECM tasks.
Get-CMDevice
Retrieves devices managed by Configuration Manager
Code:
Get-CMDevice -Name “DeviceName”
Invoke-CMSoftwareUpdateScan
Initiates a software update scan on a client device
Code:
Invoke-CMSoftwareUpdateScan -CollectionName “DeviceCollection”