PowerShell commands Flashcards
install Network Load Balancing
Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name “NLB”
join a domain
Add-Computer –DomainName sandbox.com -Credential sandbox\administrator -restart –force
disable a service
Set-Service -Name “MapsBroker” -StartupType Disabled
vs. Automatic or Manual
add/remove a vNIC from host
on host: Add-VMNetworkAdapter -VMName Sandbox-NLB02 -Name “Ethernet 2” -SwitchName Sandbox-vSwitch
(note this names it only w/in Hyper-V manager, not w/in the VM… but each new NIC will be added w/in the VM as Ethernet #)
Remove-VMNetworkAdapter -VMName Sandbox-NLB02 -Name “Ethernet 2”
set static IP addy
New-NetIPAddress -InterfaceAlias “Ethernet 2” -IPAddress 192.168.0.112 -PrefixLength 24 -DefaultGateway 192.168.0.1
install Failover Clustering
Install-WindowsFeature Failover-Clustering
install graphic failover clustering mgmt tools
Install-WindowsFeature RSAT-Clustering-MGMT
install PS failover clustering module
Install-WindowsFeature RSAT-Clustering-PowerShell
install network load balancing and tools
Install-WindowsFeature NLB
Install-WindowsFeature RSAT-NLB
stop and drain network load balancing on a single host, then start it again
Stop-NlbClusterNode -Drain -Hostname “NLBNODE2”
Start-NlbClustetNode -Hostname “NLBNODE2
discover the interface index of the adapters
Get-NetAdapter
Set IP addy by index
New-NetIpAddress -InterfaceIndex 6 -IPaddress 192.168.0.200 -PrefixLength 24
-DefaultGateway 192.168.0.1
Configure DNS addys
Set-DNCclientServerAddress -InterfaceIndex 6 -ServerAddresses
(“192.168.0.1”,”192.168.0.2”)
Rename computer whilst joining the domain
Add-Computer -DomainName foo.com -NewName ServerFoo -Credential foo\administrator
same at CMD:
1) netdom renamecomputer %computername% /newname: newcomputername
2) shutdown /r
3) netdom join %computername% /domain: domainname /userd: username /passwordd:*
(* = prompt for pw)
Update firewall to allow remote MMC management
Set-NetFirewallRule –name complusnetworkaccess-dcom-in –Enabled true
Set-NetFirewallRule –name remoteeventlogsvc-in-tcp –Enabled true
Set-NetFirewallRule –name remoteeventlogsvc-np-in-tcp –Enabled true
Set-NetFirewallRule –name remoteeventlogsvc-rpcss-in-tcp –Enabled true
install Windows Server Migration Tools
Install-WindowsFeature migration
cd C:\windows\system32\ServerMigrationTools\
SmigDeploy.exe /package /architecture amd64 /os [WS08R2|WS12R2] /path C:\Files\
… then copy results of above to source server, and run SmigDeploy.exe from elevated CMD
import nano server modules from NanoServer folder in the installation folder/media
Import-Module .\nanoserverimagegenerator -verbose
create a new standard nano server image with IP settings
New-NanoServerImage -DeploymentType guest -Edition standard -Mediapath root -Targetpath C:\Files\standardNan01.vhdx -Computername STDNAN01 -Domain foo -InterfaceNameOrIndex ethernet -Ipv4Address 192.168.1.92 -Ipv4SubnetMask 255.255.255.0 -Ipv4Dns 192.168.1.1
create a new standard nano server image from non-domain machine
on a domain machine:
>djoin /provision /domain foo /machine STDNAN02 /savefile nan02blob.txt
on non-domain machine, creating the nano:
>New-NanoServerImage -DeploymentType guest -Edition standard -Targetpath C:\Files\nan02.vhdx -Computername STDNAN02 -DomainBlobPath C:\Files\nan02blob.txt
create a new VM
New-VM -Name “STDNAN02” -Generation 2 -MemoryStartupBytes 1GB -VhdPath “D:\vhds\nan02.vhdx”
Edit nano vhd file to install VM roles/features:
- Hyper-V
- Failover Clustering
- basic Server Core drivers
- File Server
- Windows Defender
- Windows Containers
- Desired State Configuration
- DNS Server
- IIS
- System Center Virtual Machine Manager agent
- Hyper-V, managed by SCVMM
- Network Performance Diagnostics Service
- Data Center Bridging
- Secure Startup
- Shielded Virtual Machine (datacenter edition only)
Edit-NanoServerImage -basepath C:\nanoserver\base -TargetPath C:\Files\nan02.vhdx …
- -Compute
- -Clustering
- -OEMDrivers
- -Storage
- -Defender
- -Containers
- -Packages Microsoft-NanoServer-DSC-Package
- -Packages Microsoft-NanoServer-DNS-Package
- -Packages Microsoft-NanoServer-IIS-Package
- -Packages Microsoft-NanoServer-SCVMM-Package
- -Packages Microsoft-NanoServer-SCVMM-Compute-Package (do not use w/ -Compute)
- -Packages Microsoft-NanoServer-NPDS-Package
- -Packages Microsoft-NanoServer-DCB-Package
- -Packages Microsoft-NanoServer-SecureStartup-Package
- -Packages Microsoft-NanoServer-ShieldedVM-Package
Create and Enter a new nano’s PowerShell session
New-PSSession -ComputerName nan02 -credential foo\administrator
Enter-PSSession -id [##]
for local admin: -credential -\administrator
if not on a domain:
>Set-Item wsman:\localhost\client\trustedhosts “192.168.1.92”
> New-PSSession -ComputerName 192.168.1.92 -credential -\administrator
>Enter-PSSession -id ##
DISM: mount and add drivers to an offline windows image file
add packages, remove package
commit changes
> dism /get-imageinfo /imagefile:C:\images\install.wim
(shows index #s and names of available images)
> dism /mount-image /imagefile:C:\images\install.wim /index:2 /mountdir:C:\mount
> dism /image:C:\mount /add-driver /driver:C:\drivers /recurse
(adds all .inf files under that folder)
> dism /image:C:\mount /add-package /packagepath:C:\updates\thisisapackage.msu [/ignorecheck] /packagepath:C:\updates\another.msu
> dism /image:C:\mount /remove-package /packagepath:C:\updates\another.msu
> dism /unmount-image /mountdir:C:\mount /commit