April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Powershell

First, get some help

Get-Help
What better place to start than with the command that will show how to get help with the commands. Get-Helpcan be used with any command. Maybe you’re curious how the Add-Computer command works. Simply typeGet-Help -Name Add-Computer into Powershell, hit enter, and be rewarded with command details such as Name, Synopsis, Syntax, Description, Related Links, and Remarks.

Now that you know how to get help, let’s dig into the nitty gritty. Powershell commands follow the syntax ofVerb – Noun which is known as a cmdlet or command let.

Add a Feature

Install -WindowsFeature You can deploy a feature to remote computer using the –computer flag, as in:Install -WindowsFeature -Computer

Add Migration Tools

Install -WindowsFeature Migration

Switch from Full to Core

Uninstall-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell –Restart (Also using –Remove actually removes the underlying binaries)

Switch from Core to Full

Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

Switch from Full to Core Using DISM (not actually PowerShell)

Dism /online /disable-feature /featurename:ServerCore-FullServer

Install Minimal Server Interface from Core

Install-WindowsFeature Server-Gui-Mgmt-Infra

Install Minimal Server Interface from Full

Uninstall-WindowsFeature Server-Gui-Shell (Note: you can add the –WhatIf flag to see other dependent components that might also be uninstalled)

Features on Demand

Simply use Unintall-Windows Feature and include the -Remove flag to remove the binaries. To perform this on a remote computer, include -Computer

Configure IP Address

New-NetIPAddress -IPAddress 10.10.10.73 -InterfaceAlias "Ethernet" -DefaultGateway 10.10.10.1 -PrefixLength 24

Configure DNS address

Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.10.10.70, 10.10.10.1

Join Computer to Domain

Add-Computer -DomainName vegibit.com

Installing Active Directory Binaries

Install-WindowsFeature –name AD-Domain-Services

Installing New Forest

Install-ADDSForest

Installing New Domain

Install-ADDSDomain

Installing Additional Domain Controller

Install-ADDSDomainController

Uninstall Active Directory Binaries

Uninstall-WindowsFeature –name AD-Domain-Services

Uninstall Domain Controller

 

1
Uninstall-ADDSDomainController Enable Active Directory Recycle Bin Enable-ADOptionalFeature –Identity ‘CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=vegibit,DC=com’ –Scope ForestOrConfigurationSet –Target ‘vegibit.com’

 

Create new users

New-ADUser

Create Groups

 

1
New-ADGroup -Name bostonAdmins -SamAccountName bostonAdmins -GroupCategory Security -GroupScope Global -DisplayName bostonAdmins -Path “OU=User Accounts,ou=boston Admins,ou=boston,ou=Massachusetts,dc=vegibit,dc=com” -Description “boston Administrators”

 

Add Members to Group

add-adgroupmember bostonAdmins bostonAdmin01,bostonAdmin02

Advertise IPv6 on interface

set-NetIPInterface -InterfaceAlias "Ethernet 2" -AddressFamily IPv6 -Advertising Enabled

Configure Network Route for ISATAP Interface

New-NetRoute -InterfaceIndex 13 -DestinationPrefix 2001:ABCD:/64 -Publish Yes

Enable Resource Metering for Hyper-V

Get-VM -Computername | Enable-VMResourceMetering

View Resource Metering for a Specific Guest

Get -VM -ComputerName -Name | Measure -VM

Change Measurement Interval (default 1:00)

Set -vmhost –computername – ResourceMetering SaveInterval HH :MM :SS

Obtain all VMS Metering Data

Get -VM -ComputerName | Measure -VM

Obtain Specific Guest Metering Data

Get -VM -ComputerName -Name | Measure -VM

Show Storage Pools

Get -StoragePool

Show Virtual Disks

Get -VirtualDisk Repair Virtual Disk Repair -VirtualDisk

Show Unhealthy Physical Disks

Get -PhysicalDisk | Where{$_.HealthStatus –ne “Healthy”}

Remove Physical Disk from Storage Pool

Reset -PhysicalDisk

List Physical Disks Used for Virtual Disks

Get -VirtualDisk | Get -PhysicalDisk

Add a Physical Disk to Storage Pool

Add -PhysicalDisk

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>