PowerShell commands Flashcards

1
Q

install Network Load Balancing

A

Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name “NLB”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

join a domain

A

Add-Computer –DomainName sandbox.com -Credential sandbox\administrator -restart –force

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

disable a service

A

Set-Service -Name “MapsBroker” -StartupType Disabled

vs. Automatic or Manual

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

add/remove a vNIC from host

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

set static IP addy

A

New-NetIPAddress -InterfaceAlias “Ethernet 2” -IPAddress 192.168.0.112 -PrefixLength 24 -DefaultGateway 192.168.0.1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

install Failover Clustering

A

Install-WindowsFeature Failover-Clustering

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

install graphic failover clustering mgmt tools

A

Install-WindowsFeature RSAT-Clustering-MGMT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

install PS failover clustering module

A

Install-WindowsFeature RSAT-Clustering-PowerShell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

install network load balancing and tools

A

Install-WindowsFeature NLB

Install-WindowsFeature RSAT-NLB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

stop and drain network load balancing on a single host, then start it again

A

Stop-NlbClusterNode -Drain -Hostname “NLBNODE2”

Start-NlbClustetNode -Hostname “NLBNODE2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

discover the interface index of the adapters

A

Get-NetAdapter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Set IP addy by index

A

New-NetIpAddress -InterfaceIndex 6 -IPaddress 192.168.0.200 -PrefixLength 24
-DefaultGateway 192.168.0.1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Configure DNS addys

A

Set-DNCclientServerAddress -InterfaceIndex 6 -ServerAddresses
(“192.168.0.1”,”192.168.0.2”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Rename computer whilst joining the domain

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Update firewall to allow remote MMC management

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

install Windows Server Migration Tools

A

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

17
Q

import nano server modules from NanoServer folder in the installation folder/media

A

Import-Module .\nanoserverimagegenerator -verbose

18
Q

create a new standard nano server image with IP settings

A

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

19
Q

create a new standard nano server image from non-domain machine

A

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

20
Q

create a new VM

A

New-VM -Name “STDNAN02” -Generation 2 -MemoryStartupBytes 1GB -VhdPath “D:\vhds\nan02.vhdx”

21
Q

Edit nano vhd file to install VM roles/features:

  1. Hyper-V
  2. Failover Clustering
  3. basic Server Core drivers
  4. File Server
  5. Windows Defender
  6. Windows Containers
  7. Desired State Configuration
  8. DNS Server
  9. IIS
  10. System Center Virtual Machine Manager agent
  11. Hyper-V, managed by SCVMM
  12. Network Performance Diagnostics Service
  13. Data Center Bridging
  14. Secure Startup
  15. Shielded Virtual Machine (datacenter edition only)
A

Edit-NanoServerImage -basepath C:\nanoserver\base -TargetPath C:\Files\nan02.vhdx …

  1. -Compute
  2. -Clustering
  3. -OEMDrivers
  4. -Storage
  5. -Defender
  6. -Containers
  7. -Packages Microsoft-NanoServer-DSC-Package
  8. -Packages Microsoft-NanoServer-DNS-Package
  9. -Packages Microsoft-NanoServer-IIS-Package
  10. -Packages Microsoft-NanoServer-SCVMM-Package
  11. -Packages Microsoft-NanoServer-SCVMM-Compute-Package (do not use w/ -Compute)
  12. -Packages Microsoft-NanoServer-NPDS-Package
  13. -Packages Microsoft-NanoServer-DCB-Package
  14. -Packages Microsoft-NanoServer-SecureStartup-Package
  15. -Packages Microsoft-NanoServer-ShieldedVM-Package
22
Q

Create and Enter a new nano’s PowerShell session

A

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 ##

23
Q

DISM: mount and add drivers to an offline windows image file

add packages, remove package

commit changes

A

> 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