{"id":2836,"date":"2014-02-15T15:25:26","date_gmt":"2014-02-15T07:25:26","guid":{"rendered":"http:\/\/rmohan.com\/?p=2836"},"modified":"2014-02-15T15:25:26","modified_gmt":"2014-02-15T07:25:26","slug":"powershell","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2836","title":{"rendered":"Powershell"},"content":{"rendered":"<h4>First, get some help<\/h4>\n<p><code>Get-Help<\/code><br \/>\nWhat better place to start than with the command that will show how to get help with the commands.\u00a0<code>Get-Help<\/code>can be used with any command. Maybe you\u2019re curious how the\u00a0<code>Add-Computer<\/code>\u00a0command works. Simply type<code>Get-Help -Name Add-Computer<\/code>\u00a0into Powershell, hit enter, and be rewarded with command details such as Name, Synopsis, Syntax, Description, Related Links, and Remarks.<\/p>\n<p>Now that you know how to get help, let\u2019s dig into the nitty gritty. Powershell commands follow the syntax of<code>Verb \u2013 Noun<\/code>\u00a0which is known as a cmdlet or command let.<\/p>\n<h4>Add a Feature<\/h4>\n<p><code>Install -WindowsFeature<\/code>\u00a0You can deploy a feature to remote computer using the\u00a0<code>\u2013computer<\/code>\u00a0flag, as in:<code>Install -WindowsFeature -Computer<\/code><\/p>\n<h4>Add Migration Tools<\/h4>\n<p><code>Install -WindowsFeature Migration<\/code><\/p>\n<h4>Switch from Full to Core<\/h4>\n<p><code>Uninstall-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell \u2013Restart<\/code>\u00a0(Also using\u00a0<code>\u2013Remove<\/code>\u00a0actually removes the underlying binaries)<\/p>\n<h4>Switch from Core to Full<\/h4>\n<p><code>Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell \u2013Restart<\/code><\/p>\n<h4>Switch from Full to Core Using DISM (not actually PowerShell)<\/h4>\n<p><code>Dism \/online \/disable-feature \/featurename:ServerCore-FullServer<\/code><\/p>\n<h4>Install Minimal Server Interface from Core<\/h4>\n<p><code>Install-WindowsFeature Server-Gui-Mgmt-Infra<\/code><\/p>\n<h4>Install Minimal Server Interface from Full<\/h4>\n<p><code>Uninstall-WindowsFeature Server-Gui-Shell<\/code>\u00a0(Note: you can add the\u00a0<code>\u2013WhatIf<\/code>\u00a0flag to see other dependent components that might also be uninstalled)<\/p>\n<h4>Features on Demand<\/h4>\n<p>Simply use\u00a0<code>Unintall-Windows Feature<\/code>\u00a0and include the\u00a0<code>-Remove<\/code>\u00a0flag to remove the binaries. To perform this on a remote computer, include\u00a0<code>-Computer<\/code><\/p>\n<h4>Configure IP Address<\/h4>\n<p><code>New-NetIPAddress -IPAddress 10.10.10.73 -InterfaceAlias \"Ethernet\" -DefaultGateway 10.10.10.1 -PrefixLength 24<\/code><\/p>\n<h4>Configure DNS address<\/h4>\n<p><code>Set-DnsClientServerAddress -InterfaceAlias \"Ethernet\" -ServerAddresses 10.10.10.70, 10.10.10.1<\/code><\/p>\n<h4>Join Computer to Domain<\/h4>\n<p><code>Add-Computer -DomainName vegibit.com<\/code><\/p>\n<h4>Installing Active Directory Binaries<\/h4>\n<p><code>Install-WindowsFeature \u2013name AD-Domain-Services<\/code><\/p>\n<h4>Installing New Forest<\/h4>\n<p><code>Install-ADDSForest<\/code><\/p>\n<h4>Installing New Domain<\/h4>\n<p><code>Install-ADDSDomain<\/code><\/p>\n<h4>Installing Additional Domain Controller<\/h4>\n<p><code>Install-ADDSDomainController<\/code><\/p>\n<h4>Uninstall Active Directory Binaries<\/h4>\n<p><code>Uninstall-WindowsFeature \u2013name AD-Domain-Services<\/code><\/p>\n<h4>Uninstall Domain Controller<\/h4>\n<p>&nbsp;<\/p>\n<div id=\"crayon-52fefbf330eab182361352\" data-settings=\" minimize scroll-mouseover\">\n<div><\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td data-settings=\"show\">\n<div>\n<div data-line=\"crayon-52fefbf330eab182361352-1\">1<\/div>\n<\/div>\n<\/td>\n<td>\n<div>\n<div id=\"crayon-52fefbf330eab182361352-1\">Uninstall-ADDSDomainController Enable Active Directory Recycle Bin Enable-ADOptionalFeature \u2013Identity \u2018CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=vegibit,DC=com\u2019 \u2013Scope ForestOrConfigurationSet \u2013Target \u2018vegibit.com\u2019<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h4>Create new users<\/h4>\n<p><code>New-ADUser<\/code><\/p>\n<h4>Create Groups<\/h4>\n<p>&nbsp;<\/p>\n<div id=\"crayon-52fefbf330ec7419182745\" data-settings=\" minimize scroll-mouseover\">\n<div><\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td data-settings=\"show\">\n<div>\n<div data-line=\"crayon-52fefbf330ec7419182745-1\">1<\/div>\n<\/div>\n<\/td>\n<td>\n<div>\n<div id=\"crayon-52fefbf330ec7419182745-1\">New-ADGroup -Name bostonAdmins -SamAccountName bostonAdmins -GroupCategory Security -GroupScope Global -DisplayName bostonAdmins -Path &#8220;OU=User Accounts,ou=boston Admins,ou=boston,ou=Massachusetts,dc=vegibit,dc=com&#8221; -Description &#8220;boston Administrators&#8221;<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h4>Add Members to Group<\/h4>\n<p><code>add-adgroupmember bostonAdmins bostonAdmin01,bostonAdmin02<\/code><\/p>\n<h4>Advertise IPv6 on interface<\/h4>\n<p><code>set-NetIPInterface -InterfaceAlias \"Ethernet 2\" -AddressFamily IPv6 -Advertising Enabled<\/code><\/p>\n<h4>Configure Network Route for ISATAP Interface<\/h4>\n<p><code>New-NetRoute -InterfaceIndex 13 -DestinationPrefix 2001:ABCD:\/64 -Publish Yes<\/code><\/p>\n<h4>Enable Resource Metering for Hyper-V<\/h4>\n<p><code>Get-VM -Computername | Enable-VMResourceMetering<\/code><\/p>\n<h4>View Resource Metering for a Specific Guest<\/h4>\n<p><code>Get -VM -ComputerName -Name | Measure -VM<\/code><\/p>\n<h4>Change Measurement Interval (default 1:00)<\/h4>\n<p><code>Set -vmhost \u2013computername \u2013 ResourceMetering SaveInterval HH :MM :SS<\/code><\/p>\n<h4>Obtain all VMS Metering Data<\/h4>\n<p><code>Get -VM -ComputerName | Measure -VM<\/code><\/p>\n<h4>Obtain Specific Guest Metering Data<\/h4>\n<p><code>Get -VM -ComputerName -Name | Measure -VM<\/code><\/p>\n<h4>Show Storage Pools<\/h4>\n<p><code>Get -StoragePool<\/code><\/p>\n<h4>Show Virtual Disks<\/h4>\n<p><code>Get -VirtualDisk Repair Virtual Disk Repair -VirtualDisk<\/code><\/p>\n<h4>Show Unhealthy Physical Disks<\/h4>\n<p><code>Get -PhysicalDisk | Where{$_.HealthStatus \u2013ne \u201cHealthy\u201d}<\/code><\/p>\n<h4>Remove Physical Disk from Storage Pool<\/h4>\n<p><code>Reset -PhysicalDisk<\/code><\/p>\n<h4>List Physical Disks Used for Virtual Disks<\/h4>\n<p><code>Get -VirtualDisk | Get -PhysicalDisk<\/code><\/p>\n<h4>Add a Physical Disk to Storage Pool<\/h4>\n<p><code>Add -PhysicalDisk<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, get some help <\/p>\n<p>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\u2019re 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, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2836"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2836"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2836\/revisions"}],"predecessor-version":[{"id":2837,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2836\/revisions\/2837"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}