VMware Powercli Script Configure DNS server, DNS domain, and NTP services

Here’s very useful Powercli Script for VMware Administrator to set DNS server, DNS domain and NTP server values, and restart NTP.

Illustrated Examples: ESXI Configuration: Time Configuration and DNS and Routing

ESXI NTP and DNS/Routing Configure Settings:

ntpsettings

dnsanddomain

Leveraging PowerCLI Script  that configure DNS server, the DNS domain, and NTP, and starts NTP service after completing configuration.

I. Prerequisites:
a.Identify DNS server, DNS domain, and NTP information:

NTP and DNS will be same address due to NTP is enabled and reference  to pool.ntp.org

Figure #1- DNS server configuration example:-Open DNS Manager on Domain Controller or Windows Admin Tools:

dnsserverconfigurationFigure #2 – Enabling Windows 2012 to point NTP pool.ntp.org  by running command -PS C:\Windows\system32> w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:MANUAL
The command completed successfully.
PS C:\Windows\system32> Stop-Service W32Time
PS C:\Windows\system32> Start-Service W32Time

enablingntpserviceonwindows2012

Figure#3-Validate NTP status by running command
-PS C:\Windows\system32> w32tm /query /status

NTPstatusonwindows2012

 

Solution make things easier , using Powercli DNS and NTP script –
script code:

##############################################################################

# PowerCLI Script to Configure DNS and NTP on ESXi Hosts
# PowerCLI Session must be connected to vCenter Server using Connect-VIServer
# Prompt for Primary and Alternate DNS Servers
$dnspri = read-host “Enter Primary DNS”
$dnsalt = read-host “Enter Alternate DNS”
# Prompt for Domain
$domainname = read-host “Enter Domain Name”
#Prompt for NTP Servers
$ntpone = read-host “Enter NTP Server One”
$ntptwo = read-host “Enter NTP Server Two”
$esxHosts = get-VMHost
foreach ($esx in $esxHosts) {
   Write-Host “Configuring DNS and Domain Name on $esx” -ForegroundColor Green
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -DomainName $domainname -DNSAddress $dnspri , $dnsalt -Confirm:$false
Write-Host “Configuring NTP Servers on $esx” -ForegroundColor Green
Add-VMHostNTPServer -NtpServer $ntpone , $ntptwo -VMHost $esx -Confirm:$false
Write-Host “Configuring NTP Client Policy on $esx” -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{$_.Key -eq “ntpd”} | Set-VMHostService -policy “on” -Confirm:$false
   Write-Host “Restarting NTP Client on $esx” -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{$_.Key -eq “ntpd”} | Restart-VMHostService -Confirm:$false
}
Write-Host “Done!” -ForegroundColor Green
Write-Host “Done!” -ForegroundColor Green
###########################################################################

II. Download NTP_DNS PowerCLI Scource Code:

[embeddoc url=”http://blog.itsysintegration.net/wp-content/uploads/2015/11/NTP_DNS.zip” download=”all”]

III. Step by Step How To Configure DNS and NTP for newly built ESXI host.

a. Launch PowerCli and Run As Administrator

openpowercli

b. Log into the ESXI Host via PowerCLI

esxilogon

c. Execute NTP_DNS.ps1> type .\NTP_DNS.ps1

Ntp

d. You will get a prompt to input Primary, Alternative DNS, Domain Name, NTP Server one and two.:

primarydns

e. DNS_NTP script updates the both DNS and NTP on ESXI Host and Start NTP services.

finaldnsntpssettings

NTPrestrt

 

Reference:

NTP and DNS PowerCLI cmd-let
https://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Set-VMHostNetwork.html


Enabling NTP on Windows 2013
http://www.sysadminlab.net/windows/configuring-ntp-on-windows-server-2012

Vmware PowerCli Mount Datastore Script

Here are some useful Powercli Script post building ESXI Hosts:

1. Mount Datastore(s) to ESXI Host PowerCLI script.

We all know mounting NFS Datastores to newly built ESXI hosts can be very tedious task, imagine, you have 20 ESXI Host and at least 5 to 20 multiple NFS Datastores to mount?

 

Mount Network File Share Datastore  – Manual process mount datastore via Vsphere UI will take forever. 

Solution make things easier , using Powercli script – New-Datastore script method- mounting multiple Datastore script code.

Below I will show script method that will save time for VMware Administrators.

I. Mount Datastore Script Configuration.

Save below script code as Mount_Datastore.ps1

############################################################################

#Connect to the VI Server if you are not connected already remove the comment designator
#This script mount NFS Datastore.
‘Reading CSV file’
#location of where datastore.csv is stored.
$vms = Import-CSV C:\Scripts\datastore.csv
‘Reading the contents of the CSV, and for each line execute the following code’
foreach ($vm in $vms){
‘Declaring variables that correspond to the column names in the CSV’
$vmhost = $vm.host
$dhost = $vm.dhost
$dpath = $vm.dpath
$dname = $vm.dnameWrite-Host “Creating Datastore on $vmhost”
‘Datastore mapping’
New-Datastore -nfs -vmhost $vmhost -name $dname -path $dpath -NfsHost $dhost}
‘Ending Script’
#################################################################################
II. Datastore.csv configuration:
#################################################################
host,dhost,dpath,dname
# ESXI host IP or FQDN, datastore server IP or Host,  Data Folder, Datastore Identification ,
Mvp-vs02.mvp.local, 192.168.2.9,/mnt/esx-vg1/app_volume/App_Datastore/App/, App,

 ####################################################################

ESXI host IP or FQDN: Figure#1

exihost

 NFS Datastore IP or Host, Folder, Datastore Identification: Figure #2

datastoreidentifer


 Step 2. Create a Datastore.csv with below configuration.

#################################################################

host,dhost,dpath,dname
# ESXI host IP or FQDN, datastore server IP or Host,  Data Folder, Datastore Identification ,
Mvp-vs02.mvp.local, 192.168.2.9,/mnt/esx-vg1/app_volume/App_Datastore/App/, App,
 ####################################################################
Step 3. Save mountdatastore.zip in a folder called scripts and copy it to local machine.

[embeddoc url=”http://blog.itsysintegration.net/wp-content/uploads/2015/11/mount_datastores.zip” download=”all”]

IV. Step by Step Illustration

1. log into the ESXI host via powercli

a .Launch Powercli and Run as Administrator.

 

openpowercli

B. Log in to the single entity ESXI Host by entering:

Connect-VIserver servername and ESXI host IP or Host
mountdatastoree1

C. Prompt to Input Root Credentials

esxihostroot

D.  Navigate to where Mount Datastore is locate on your desktop via Powercli Command Line.
I.E:  Datastore.cvs and Mount_datastore.ps1

mountdatastorefiles

E. Edit Datastore.csv with all multiple datastores to be mount.

I.E shows datastore.csv should look like
datastorecsvconfg

F. Execute the mount_datastores.ps1 script by typing the .\mount_datastores.ps1

runpwershel

G. Mounted Datastore Successful on ESXI Host.

mounsuccess1

mountscriptworked

Here is an example of multiple Datastores entries added to the datastore.csv.

*Notice the 1 datastore entry was already mounted in 1st script example, the script know it’s already mount and skips it.

New-Datastore : 11/21/2015 11:44:46 PM    New-Datastore        The name ‘App’ already exists.
At C:\Users\richard\Desktop\Powercli\New folder\Mountdatastore\mount_datastores.ps1:16 char:4
+       New-Datastore -nfs -vmhost $vmhost -name $dname -path $dpath -N …
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [New-Datastore], DuplicateName
+ FullyQualifiedErrorId : Client20_VmHostServiceImpl_NewNfsDatastore_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewDatastore

mountdatastorescript

Newly Datastore Mounted to ESXI Host.

Declaring variables that correspond to the column names in the CSV
Creating Datastore on 192.168.2.233
Datastore mapping
WARNING: Parameter ‘VMHost’ is obsolete. This parameter no longer accepts multiple values.
Name                               FreeSpaceGB      CapacityGB
—-                               ———–      ———-
APP3 NAS2 Datastore                     85.823         186.533
Declaring variables that correspond to the column names in the CSV
Creating Datastore on 192.168.2.233
Datastore mapping
WARNING: Parameter ‘VMHost’ is obsolete. This parameter no longer accepts multiple values.
App4                                   755.104       1,096.120
Declaring variables that correspond to the column names in the CSV
Creating Datastore on 192.168.2.233
Datastore mapping
WARNING: Parameter ‘VMHost’ is obsolete. This parameter no longer accepts multiple values.
OS Datastore                           162.606         323.842
Declaring variables that correspond to the column names in the CSV
Creating Datastore on 192.168.2.233
Datastore mapping
WARNING: Parameter ‘VMHost’ is obsolete. This parameter no longer accepts multiple values.
System Datastore                        31.323          95.297
Ending Script
I. E – ESXI Host with more add datastores mount to it.
exishostmountdatastore
Reference:
New-Datastore PowerCLI Command

Powershell-Major Features

Major Features:

  • Cmdlets
  • Pipeline
  • Providers
  • Help System

 


Cmdlets (also pronounced it “command-let”)
 are probably the most obvious feature when comparing Powershell to other scripting language. A cmdlet is a small, self contained piece of functionality that does one specific job.

For example: Get-command | Where {$_.pssnapin -like “Microsoft.p*.”}). count

 

The Get-Command generates a list Powershell commands and list is piped in a filter 

..(Where is the an alias or shorthand for where-object) that accepts those commands installed by a Powershell snapin. The method of extending powershell whose names start Microsoft P. Then count the number of commands in the filerterd list. As illustrated in Figure #1.

Figure#1.
PS C:\Users\ (Get-Command |where {$_.pssnapin -like “Microsoft.p*” } ).count
60

powershellgetcommand

Cases and Operators:
The operator -like is used to perform the comparison in the Figure#1- For example,  

All cmd-lets has a verb-noun syntax. It starts with verb. The second part is a nount that describes what the verb is actingin on – in this case.

Get-Command with -Noun and -Verb

As you get to know PowerShell better so you become familiar with verbs such as ‘Set’ or ‘Get’ and nouns such as ‘Process’ or ‘Computer’.  This is why I now prefer to filter Get-Command with -Noun or -Verb.  One of my greatest successes was finding ‘Restart-Service’.  I had used start and stop-service, but when I tried this filter I unearthed the useful Restart-Service.

# PowerShell Get-Command Nouns
Clear-Host
Get-Command -Noun Service

Also Verbs

# PowerShell Get-Command Nouns
Clear-Host
Get-Command -Verb S*

Note 2: I could have chosen -Verb Set, but I wanted to show you that -Verb also take wildcards*.

Get-Command -Module

Firstly list your modules with Get-Module.  Make your selection, for example, ISE.

# PowerShell Get-Command Module info
Clear-Host
Get-Module ISE

Here is another example which imports a modules then checks the cmdlets.

$Baskets = “PSDiagnostics”
Import-Module $Baskets
Get-Command -Module $Baskets

Tab Completion:
Powershell demonstrators another feature that aids productivity: Tab completion. If you type Get- and press tab key, the PowerShell engine will complete the command with the first cmdlets that matches what been typed.

As with the cmdlets names, the more of the paramters name you give, the sooner the process brings.

Aliases
As an alternative to typing the full name of a cmdlet or parameters, it’s possible to use an alias.

alaispowershell

Creating a New Windows PowerShell Alias

So you say that you like Windows PowerShell, but you have problems remembering some of the cmdlet names? Well, then why not create an alias for those cmdlets, an alias that you can remember? For example, maybe you’d prefer to type show instead of Get-ChildItem. If that’s the case, then you can use the New-Alias cmdlet to map the term show to Get-ChildItem. All you have to do is call New-Alias followed by the alias name (show) and the cmdlet the alias is being mapped to (Get-ChildItem). You know, something like this:

New-Alias show Get-ChildItem

Now, what do you suppose will happen the next time you type show in the Windows PowerShell console? You got it:

Windows PowerShell
By default, aliases are not saved between Windows PowerShell sessions: each time you restart Windows PowerShell you’ll need to recreate the alias. To ensure that your new aliases survive between Windows PowerShell sessions, create a PSConfiguration folder in your Windows PowerShell profile folder. For example:

C:\Documents and Settings\gstemp\My Documents\PSConfiguration

Note. How are you supposed to know your Windows PowerShell profile folder? Just type this command:

Get-Variable profile | Format-List

In the PSConfiguration folder, create a file named Microsoft.PowerShell_profile.ps1 and add the following command to the file:

Set-Alias show Get-ChildItem

 

 

 

 

Reference:
Powershell cmdlet Verb-Noun 
https://technet.microsoft.com/en-us/library/dd315315.aspx

VMware vCenter Orchestrator Applicance-5.5.3

vCenter Orchestrator (vCO) 5.5 – Part 1 Deploying the Virtual Appliance

vCenter Orchestrator (vCO) is a product which allows you to create tasks and automated workflows which and be run directly within vSphere Web Client or the vCenter Orchestrator Client.

There are a number of pre-made workflows to get your started, and the number of tasks you can perform is quite amazing. Any task that can be performed in vCenter can be automated through vCO, and thats just the start. Add some Active Directory integration, API’s and other 3rd party plugin’s.

Workflows can be anything from simple workflows that contain a single task to say create a virtual machine, to complicated workflows containing many tasks that might build an entire solution and integrate with 3rd party plugins.

One of the best things about vCO is it’s included with vCenter Server and it’s free!

Here are high levels of the VCO 5.5 configuration Guides will cover.

  • vCenter Orchestrator (vCO) 5.5 – Part 1 Deploying the Virtual Appliance
  • vCenter Orchestrator (vCO) 5.5 – Part 2 Configuring vC
  • vCenter Orchestrator (vCO) 5.5 – Part 3 Using vCO and Running a Workflow

 

The latest version of vCenter Orchestrator (vCO) is 5.5.1 and has come on leaps and bounds since I originally saw it. This is my first proper look into vCO, it’s features and it’s going to take some time getting used to it. Not because it’s difficult to use, more because the possibilities seem quite endless and understanding what cool things are possible might take some time to discover. However I did find it difficult to find a decent resource to quickly get it up and running and hopefully this blog will address that for others.

 

vCO can be deployed in a number of ways, all achieve the same end solution and integrate with vSphere Web Client and Single Sign On.

  • Installed on a Windows Server (Co-installed with vCenter Server)
  • Installed on a Windows Server (Standalone)
  • Virtual Appliance

 

Production deployments such use a SQL server (not SQL express or the embedded DB in the appliance).

I’m going to use the virtual appliance and the embedded PostgreSQL database in my lab. I had to choose one and as I understand vCO so far there are no gotcha’s using the VA so I thought I’d go for that.

The virtual appliance weighs in at 2vCPU, 3GB vRAM and 12GB vDisk (Thick provisioned)

1. You may have noticed the vCenter Orchestrator plugin within the vSphere Web Client. Following the vCO icon takes you into vCenter Orchestrator with 0 vCO servers and no workflows.

 

2. Download the vCO Server Virtual Appliance

3. Deploy the vCO .ova template to the ESXi host or cluster.

 

deployovftemplate

 

4. Select the .ova file, Next.

vcoovadeploy

 

5. Check the vCO version and size on disk, Next.

 

vcoovadeploy2

 

6. Accept the EULA (Click Accept), Next.

 

vcoovadeploy3

 

7. Give the vCO VA a name (I chose VCO1), select a DC or folder, Next.

 

vcoovadeploy4

 

8. Select Thick or Thin provisioned disk and the datastore to deploy to, Next.

vcoovadeploy6

9. Select the network to connect to and choose IP protocol IPv4, Next.

10. Enter a complex password (8 chars, include UPPER, lower, number and spec!al char)

11. Enter the Default GW, mask, IP address and DNS server IP.

 

vcoovadeploy8

 

12. Review your settings, tick “Power on after deployment” and Click Finish!

 

vcoovadeploy9

 

13. You will see the “Deploy OVF template” task run, this will take several minutes.

14. While you wait for it to deploy create a DNS A record for your vCO appliance
(e.g. vco.mvp.local)

 

vcoovadeploy10

 

 

15. Once the vCO virtual appliance has finished deploying it will power on.

Checking the console you will see that the appliance has booted and has the correct IP address, we are now ready to configure the appliance and vCO.

 

Note: Check you can ping the DNS name you created earlier (e.g. vco.mvp.local)

vcoconsoleview

 

1. Now you have the vCO appliance deployed, powered on and it has an IP address (plus the DNS A record you created)

dnsentry

 

2. Open your web browser to <ip address or FQDN> ” port 8283

https://vco.mvp.local:8283

https://vco.mvp.local:8283

3. Login with Username: VMware

Password: <The Password Set During OVF Deployment>

vcologon

4. Now you are logged into the vCO Configuration page, here we need to make a number of configurations before vCO will work.

 

5. First go to Network –> SSL Trust manager

6. You want to import from URL your vCenter and SSO certificates so you can connect to them later on in the config

 

e.g. https://vcenter01.mvp.local and https://vcenter01.mvp.local:7447

vconetworkcfg

 

7. You will be prompted to accept the certificate. Click Import.

 

 

 

8. You will now see your certificates within the SSL Trust Manager

 

 

vconetworkcfg1

9. Go to Authentication

You can use either SSO or LDAP Authenication. in below example, We will use LDAP Authenication.

 

10. Select “LDAP Authenication”

(*For SSO Authenication you can us below administrator@vsphere.local.

*Enter your SSO server details (e.g.,https://vcenter01.mvp.local:7447 your SSO administrator (this might be administrator@vsphere.local and  SSO administrators password)

 

11. Click Register Orchestrator.

 

authenication

13. Now you need to select a “vCO Admin – domain and group” you can manage vCO (this could be vsphere.local Administrators, or your Domain Admins group if configured in SSO)

 

14. Click Update Orchestrator Configuration, all the dots next to the config items will turn green indicating that config is complete.

 

15. Go to vCenter Server

16. We need to add a vCenter Server so browse to the New vCenter Server Host tab and enter the details of a vCenter Server, Click Apply Changes.

17. Check your vCenter Server has been added in the Hosts tab.

18. Go to Licenses

19. Select “Use vCenter Server license” and enter your vCenter server details

20. Go to Plug-ins

21. Ensure the plugins are enabled, enter your SSO user and Click Apply changes

22. Go to Network

23. In the IP Address box select the IP address that the vCO service should bind to and Click Apply

24. Go to Startup Options

25. Under vCO Server, Click “Restart service”.

This will restart the vCO service, binding the vCO service to the correct network interface and also set the SSO authentication.

  • vCenter Orchestrator (vCO) 5.5 – Part 3 Using vCO and Running a Workflow

vcosnaphshot30daysRemove old snapshots 30 days. 

 

snapshotremoveworkflowsnapshotremovalworkflow2Vcenter Tasks Show Snapshot are remove based on VCO Remove Old snapshots -< 30 days criteria-  
snapshotremoveal
snapshotremovallogs

Reference
VMware vCenter Orchestrator Applicance 
https://www.vmware.com/support/pubs/orchestrator_pubs.html

 

Powershell-Build-In Command Line Tools

Powershell has a build-in command line tools-

powershell

  • Get-Help
  • Get-Command
  • Get-Member
  • Get-PSDrive

Get-Help command line based analogous to the main files available

  •  Information specific to an individual CMDLET, for example, Get-Help followed by the cmdlet name
  • Powershell lanaguage and evnironment information, accessed by Get-Help followed by about_topic _name.

 

Helpcommand

Helpcommand2Get-Help

Display information about Windows PowerShell cmdlets and concepts.

Syntax
Get-Help [[-name] string] [-component string[]]
[-functionality string[]]
[-role string[]] [-category string[]]
[ {-full | -detailed | -examples | -parameter string}]
[-Online] [-Path string] [CommonParameters]
Key
-name
Request help about string
A cmdlet name, topic, alias, script or function name. Wildcards are permitted.
e.g. -name Get-Member, -name “About_Object”, -name “ls”
The “-Name” is optional.

-category
Display help for items in the specified category.
Valid values are:  Alias, Cmdlet, Provider, and HelpFile.
Conceptual topics are in the HelpFile category.

-component
Display a list of cmdlets with the specified component value,
such as “Exchange.”

-detailed
Display additional information about a cmdlet, including
descriptions of the parameters and examples of using
the cmdlet. This parameter has no effect on displays
of conceptual (“About_”) help.

-examples
Display examples of using the cmdlet.
To display only the examples, type
“(get-help cmdlet-name).examples”.

-full
Display the entire help file for a cmdlet, including
technical information about the parameters.
This parameter has no effect on displays of
conceptual (“About_”) help.

-functionality
Display help for cmdlets with the specified functionality.
Wildcards are permitted.

-Online
Display the online version of a help topic in the default Internet browser.
This parameter is valid only for cmdlet, function, and script help topics.
see Help about_Comment_Based_Help

-parameter
Display a detailed description of the specified parameter.
These descriptions are included in the Full view of help.
Wildcards are permitted.

-Path string
Get help that explains how the cmdlet works in the specified provider path.
Enter a Windows PowerShell provider path.

This parameter is effective only for help about a provider cmdlet and only when
the provider includes a custom version of the provider cmdlet help topic.

Go to the provider path location and enter Get-Help or, from any path location,
use Get-Help -Path. For more information, see about_Providers.

-role String
Display help customized for the specified user role.
The role that the user plays in an organization.
This parameter has no effect for the core cmdlets.

CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.

Get-Command

Commands are the fundamental part of any shell language: ;They are what you type to get things done.

command – parameter1 -parameters2 argument1 argument2

|               |                  |                    |                |

command name : switch parameter : parameter with argument”  positional argument”

Get-Command is complementary to Get-Help. For example, you type Get-Command at the Powershell prompt, you will see Alissa, Functions and Cmdlet ”

getcommand

getcommand2

For example, Get-Command ipconfig.exe: |format -List

getomandipconfigGet-Member

Get-Member is the best described as the Swiss Army knife of Powershell, Type; Get-Help Get-Member to display it.

Getmember

NAME
Get-Process

SYNOPSIS
Gets the processes that are running on the local computer or a remote computer.

SYNTAX
Get-Process [[-Name] [<String[]>]] [-ComputerName [<String[]>]] [-FileVersionInfo] [-InformationAction {SilentlyContinue
| Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-Module] [<CommonParameters>]

Get-Process [-ComputerName [<String[]>]] [-FileVersionInfo] [-InformationAction {SilentlyContinue | Stop | Continue |
Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-Module] -InputObject <Process[]>
[<CommonParameters>]

Get-Process [-ComputerName [<String[]>]] [-FileVersionInfo] [-InformationAction {SilentlyContinue | Stop | Continue |
Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-Module] -Id <Int32[]> [<CommonParameters>]

Get-Process [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] -Id <Int32[]> -IncludeUserName [<CommonParameters>]

Get-Process [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] -IncludeUserName -InputObject <Process[]> [<CommonParameters>]

Get-Process [[-Name] [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore |
Suspend}] [-InformationVariable [<System.String]>]] -IncludeUserName [<CommonParameters>]

DESCRIPTION
The Get-Process cmdlet gets the processes on a local or remote computer.

Without parameters, Get-Process gets all of the processes on the local computer. You can also specify a particular
process by process name or process ID (PID) or pass a process object through the pipeline to Get-Process.

By default, Get-Process returns a process object that has detailed information about the process and supports methods
that let you start and stop the process. You can also use the parameters of Get-Process to get file version information
for the program that runs in the process and to get the modules that the process loaded.

RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/p/?linkid=290498
Debug-Process
Get-Process
Start-Process
Stop-Process
Wait-Process

REMARKS
To see the examples, type: “get-help Get-Process -examples”.
For more information, type: “get-help Get-Process -detailed”.
For technical information, type: “get-help Get-Process -full”.
For online help, type: “get-help Get-Process -online”

Get-PSDRIVE

Get-PSDRIVE displays information about the providers that are currently installed. Full details were supplied

Get-PSDrive

getdrive

Get drive information (gdr)

Syntax
Get-PSDrive { [[-name] string[]] | [-literalName] string[]  }
[-Force] [-pSProvider string[]] [-scope string]
[-UseTransaction] [CommonParameters]

Key
-name string
Get only the specified drives.
Type the drive name or letter without a colon (:),
separate multiple names with commas.

-literalName string
The Drive name which will be used exactly as typed.
No characters are interpreted as wildcards. If the name includes escape
characters, enclose it in single quotation marks.

-pSProvider
Get only the drives supported by the specified PowerShell provider.
Type the name of a provider, such as:
FileSystem, Registry, or Certificate.

-scope
The scope within which to search for the drive.
Valid values are “Global”, “Local”, or “Script”, or a number relative
to the current scope (0 through the number of scopes, where 0 is the
current scope and 1 is its parent).
“Local” is the default. For more information, see about_Scopes.

-UseTransaction
Include the command in the active transaction.

CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.

Standard Aliases for Get-PSDrive: gdr

Get-PSDrive gets the PowerShell drives in the current session. You can get a particular drive or all drives in the console.

Get-PSDrive gets the following drives:

– Windows logical drives on the computer, including drives mapped to network shares.
– Drives exposed by PowerShell providers (such as the Certificate:, Function:, and Alias: drives) and the HKLM: and HKCU: Registry drives.
– Drives created with New-PSDrive.

Get-PSDrive does not get Windows mapped drives that are added or created after the PowerShell console is opened.

Examples

Display information about all currently visible drives:

PS C:\> get-psdrive

Display the description of a PowerShell drive on your system:

PS C:\> (get-psdrive DriveName).description

Display information for drives with names that begin with HK (registry: HKLM, HKCU etc):

PS C:\> get-psdrive HK*

Display information for FileSystem drives:

PS C:\> get-psdrive -psprovider filesystem

References:
Powershell.exe Command Line Help.
https://technet.microsoft.com/en-us/library/hh847736.aspx

 

Vmware vRealize Automation IAAS Installation

 vRA-IAAS- Install on Window 2012 

Prerequisite:

IaaS Database Server Requirements: These are the general requirements for the IaaS Database (SQL Server). TCP/IP protocol enabled for MS SQL ServerMicrosoft Distributed Transaction Coordinator Service (MS DTC) enabled on all SQL nodes in the system

Microsoft Distributed Transaction Coordinator (MS DTC) helps you control the coordination of transactions between applications and resource managers. Depending on the network topology of these components, a transaction can span multiple DTCs throughout your network.

To allow transactions to be coordinated across the network, Network DTC Access must be enabled on all MS DTC instances that are participating in the transaction. For example, if a COM+ object attempts to update a Microsoft SQL Server® database on a remote computer by using an MS DTC transaction, the transaction fails if network transactions are disabled. Similarly, if the computer hosts a SQL database that has remote applications that try to access the database by using an MS DTC transaction, those transactions also fail if Network DTC Access is disabled.

To enable Network DTC Access for MS DTC transactions


  1. Open the Component Services snap-in.To open Component Services, click Start. In the search box, type dcomcnfg, and then press ENTER.
  2. Expand the console tree to locate the DTC (for example, Local DTC) for which you want to enable Network MS DTC Access.
  3. On the Action menu, click Properties.
  4. Click the Security tab and make the following changes:
    • In Security Settings, select the Network DTC Access check box.
    • In Transaction Manager Communication, select the Allow Inbound and Allow Outbound check boxes.
  5. Click OK.

iaassqlconfiguration

No firewalls between Database Server and the Web server or IaaS Server, or ports opened as described in Port Requirements

IAASVcloudAutomationfirewall4

IAASVcloudAutomationCFG

 

1.Login to the installer using root and password specified during the deployment of the vRA applianceAs this is the first IaaS server, I will be installing all the roles on this server (Will add a secondary DEM Orchestrator and DEM worker to another server later). Therefore select Complete Install and click next 3.4

The built-in Pre-Requisite checker will now verify that you’ve got all the pre-requisites and confirm.

IAASVcloudAutomationCFG12 IAASVcloudAutomationCFG11 IAASVcloudAutomationCFG10 IAASVcloudAutomationCFG9 IAASVcloudAutomationCFG8

Powershell -Profiles-All About

sshot-2010-01-19-17-54-54

A Powershell profile is a script that eecutes when Powershell is first started. Profiles are used to cinfigure Powershell and load extra functionality automamatically at startup.

Profiles make the application of a standard, repeatable configuration much easier. There are four separate profiles in Powershell. IN order of loading, the profiles are:

  1. $pshome\prifle.ps1
  2. $pshome\Microsoft.Powershell_profile.ps1
  3. $home\My Documents\WindowsPowershell\profile.psb1
  4. $home\My Document\WindowPowerShell\Microsoft\profile.ps1

For frequent PowerShell users, the standard settings might not be ideal. We can change the settings of our PowerShell window to how we like it by modifying the profile.

The first thing we need to check is whether or not a profile already exists. We can do this by opening a PowerShell window and typing:

Test-Path $profile

 

Since our query returned “False” we are going to have to create a new profile. We’ll type the following in our PowerShell prompt:

New-Item -path $profile -type file –force

sshot-2010-01-19-17-47-21

You should get the following pop-up, and just click yes to proceed.

sshot-2010-01-19-17-41-36

The profile script will now be created. It will be in the location following the “Directory:” output. When we browse to that location, the profile script will be there waiting for us to modify. Open the file named “Microsoft.Powershell_profile.ps1

 

The profile will be empty, so we can fill it with any commands that we want to run. You can set the starting prompt location to the root directory by adding:

set-location c:

We can change the title of the PowerShell window to SysadminGeek by adding:

$Shell.WindowTitle=”SysadminGeek”

We can also change the window size and scrollback with the following:

$Shell = $Host.UI.RawUI
$size = $Shell.WindowSize
$size.width=70
$size.height=25
$Shell.WindowSize = $size
$size = $Shell.BufferSize
$size.width=70
$size.height=5000
$Shell.BufferSize = $size

The background and text coloring can also be changed with these entries:

$shell.BackgroundColor = “Gray”
$shell.ForegroundColor = “Black”

You can put any scripts or aliases that you commonly use as well. We’ve included our alias forNotepad.exe

new-item alias:np -value C:WindowsSystem32notepad.exe

The final entry is included to clear everything from the PowerShell window, giving you a clean workspace:

Clear-Host

All together, it looks like this:

sshot-2010-01-19-19-45-59

After you’ve saved your profile, the next time you open PowerShell you will see all the changes made to your profile.

 

It’s pretty easy to customize your profile, and the more you use PowerShell, the more you will find yourself returning to add in new aliases and scripts that you need to run at startup

Summary of Powershell locations

All shells Standard PowerShell
All Users $pshome\profile.ps1 $pshome\ Microsoft.Powershell_profile.ps1
Idividual user ..\My Document\WindowsPowershell\Profile.ps1 ..\My Documents\

WindowsPowershell\Microsoft.PowerShell_profile.ps1.

 

$pshome is the path to the Powershell installation folder.. PowerShell doesnn’t create any profiles during the installation process.  All profiles have to be created manually. You can centralized Profile to reference share or unc path.

Profiles can perform several actions:

  • Loading additional functionality via PowerShell snapins
  • Creating functions and storing in memory for future use
  • setting the PowerShell prompt
  • Running scripts
  • Setting environmental factors such as color schemes
  • Changing the current folder.

A folder containing an example profile is created when Powershell is installed.  32 bit refernce is C:\Windows\Systems32\WindowsPowerShell\v(x)\

Microsoft.PowerShell_profile with Windows Explorer

Preparation:  Navigate to your Windows directory called,
Users
or
‘Documents and Settings’.
Now find a sub folder called: %username%\My Documents\WindowsPowerShell e.g.
C:\Users\YourName\My Documents\WindowsPowerShell
N.B. This folder is now called WindowsPowerShell (not PSConfiguration)

PowerShell Profile in Windows 7
PowerShell Microsoft.PowerShellISE_profile

Note 5:  Observe the above filenames: Microsoft.PowerShell_profile is for the command-line, while the GUI version has ISE in the filename.

PowerShel Profile.ps1

PowerShell Profile Location
 Locating the path for Profile.ps1. C:\Documents and Settings\All Users\Documents\PSConfiguration\profile.ps1

 

Reference
Richard Siddaway -Powershell In Practice

MS Powershell -All About

MSPowershellWhat is  PowerShell?

Powershell is Microsoft’s newest scripting language
focused on providing administrators with an easy and
powerful way to perform certain tasks.

Why should I brother with Powershell? 

Powershell versatility new technology “Eureka moments”

Here are a few features:

  • Windows OS Administration Cmdlets
  • Logon Scripts
  • WinPE environment
  • AD and Exchange Management(ADSI)
  • Cmdlets
  • Pipeline
  • Providers
  • Help systems

powershell

Supported Environments:,Window 7, Windows 8.1 and Windows 2K8 and 2K12.

II. Powershell 4.0 or 5.0 DownloadRequired:
Powershell 4 or 5 Download Reference

i. Powershell 5. 

Windows Management Framework (WMF) 5.0 Preview April 2015 contains functionality that has been updated from WMF 4.0. WMF 5.0 Preview April 2015 is available for installation on Windows 8.1, Windows Server 2012 R2, Windows Server 2012, Windows 2008 R2 and Windows 7, and contains updated versions of the following features:

PowerShell is either included or can be downloaded and installed on the following operating systems:

Why Powershell?

ii. OS and Service Pack Requirements:

Operating System Service Pack Level Editions
Windows 8.1 All
Windows Server 2012 R2 All except IA64
Windows Server 2012 All except IA64
Windows Server 2008 R2 SP1 All except IA64
Windows 7 SP1

1II. Installing PowwerShell on Windows Platform- For this demonstration, we will install Powershell 5.0 on windows 7 Professional SP1. Workstation Edition.

a. Download (Powershell 4 or 5 Download Reference) and Install Powershell 5.0 on Workstation Platform. 

*Illustrates which Power shell versions specific to the Server 2k(8 and 12) or Workstation(7 sp1 or 8.1) Platform Environment.

powershell1

powershell2

*Please note – click here will ease any download issue specific to client workstation web browsers pop up blocker 

b. Copy Windows61.-KB2908075-x64.msu locally on the workstation client and open. 

powerinstall5.01

c. Click Yes to continue with installation.

power5install2

d. Click I agree with EULA to proceed with installation.

powershell5install2*installation in progress- Restart workstation 

powershell5install3II. Open PowerShell – Search Powershell in windows search –

a.Right Click on Windows Powershell -Run As Administrator.

searchpowershellrunpowershellrunasadmin

 

b.  Enable Poweshell Script Execution

Note: As a security precaution remote PowerShell scripts cannot be executed unless you enable it. This is required before VMware commands can be executed.

i. Type in the Powershell CommandLine: set-ExecutionPolicy RemoteSigned.

The powershell execution policy determines where scripts can be run and if they need to be digitally signed.

powershellremotesingedII. Type Y =(Yes) to allow to change the exution policy to set-ExcutionPolicy Remotesigned.

III. Install the Vmware Powershell ComponentsSnap-Ins and Modules

*Please notes there are 2 main ways to extend the shell,  we will be add snap in method. 

Modules – A package that contains Windows PowerShell commands int he form of functions, cmdlerts and workflows, in addition it may contain variables, aliases and providers. Modules can be written in PowerShell and/or compiled as DLLs.

Snap-Ins – Are compiled cmdlets in to a DLL written in a .Net language are being deprecated and no longer recommended as the way to create and package new cmdlets.

Install the VMware PowerShell Components  by Installing  the Wmware ‘PowerCLI’ onto your local PC that contains the VMware software management objects and Cmdlets

*Reference Install PowerCLI  Section- if have not install PowerCLI before.

IV. Registrered – PSSnapin – Vmware.Automation Cmdlets- Open the VMware (not Windows) PowerShell-  Type- Get-Command -Noun PSSnapin.

a. PS C:\> get-command -noun pssnapin components.
PSSnapinregistred

b. PS C:\> Add-PSSnapin VMware.VimAutomation.Core and  PS C:\> help vm illustrate all Vmware.VIMAutomation.Core CMDLETS

addpsnapinmoduleC: Import-modules:

Copy powershell Modules to local machine  and navgiate to directoy.. Type import-module .\<module file name>

Module comes with Powershell 5.  under C:\Windows\System32\WindowsPowerShell\v1.0\Modules\

powershellmodules

 

PS C:\scripts\InfraTools\PowerCLIBook\PowerCLIBook> Import-Module .\PowerCLIBook.psd1

VERBOSE: Importing function ‘Add-DistributedSwitchVMHost’.
VERBOSE: Importing function ‘Backup-MsSqlDatabase’.
VERBOSE: Importing function ‘Backup-VcConfig’.

For example below modules are made up of four files:

  • PowerCLIBook.psd1 – The PowerShell module manifest file, which describes the contents of the module and controls how the module is processed.
  • PowerCLIBook.psm1 – The PowerShell module file containing the functions which make up the PowerCLIBook module.
  • DistributedSwitch.psm1 – The PowerShell module file containing the functions which make up the DistributedSwitch nested module, if you like a sub-module of the PowerCLIBook module.
  • Test-Version.ps1 – A script which is run prior to the PowerCLIBook module being called which checks to see if PowerCLI 4.1 or newer is installed.

 * will importing all above modules*

  • From your PowerShell session you will now be able to see that the PowerCLIBook Module is available:

Get-Module -ListAvailable

getmoduleliset

  • To use functions from the module it needs to be imported into the current session:

Import-Module PowerCLIBook

  • To view what functions are now available (in total there are 79!):

Get-Command -Module PowerCLIBook

powerclibook1To view the comamnds specific to Distributed Switches:

Get-Command *DistributedSwitch*

getmoduleliset32To get help on one of the functions:

Get-Help Set-DistributedSwitch -Detailed

  • To view the help examples for a function

Get-Help Set-DistributedSwitch -Examples

D. Test Vmware Powershell CMDLET – Open the VMware (not Windows) PowerShell
Command Prompt and type the following:

1. Connection to Vcenter or ESXI Host : Syntax Example

Connect-VIServer -Server
<vCenterIPAddress> -User
<adminUsername> -Password <password>

PS C:\> Connect-VIServer -Server mvp-vs01.mvp.local

connectesxhostviapowershell

2.  User and Password Prompt- Input Vcenter or ESXI User ID and Password. 

powershelluseridpromptesxi

*Unsigned Certificate haven’t been configured then see a warning- This can be ignored. 

3. User Successful Authenticated to ESXI or Vcenter. 

ESXI- User Root 

ESXIrootuserauthenicationsuccesfully

Vcenter-Domain User-

powershellvcenter1

4.  List Vmware CMDLET- Typing help VM:

*Notice there more option; Click Spacebar to more of the Vmware CMDLET.

listvmcmdletpowershellSample of Example Commands:

PowerShell Command= Action
Start-VM <guestVMname> =Power on the VM specified
ShutDown-VMGuest <guestVMname> =Shuts down Guest OS
Get-DRSRule –Cluster <ClusterName>=Displays DRS rules for specified cluster
Note: All commands above are entered as one line

6. Execute  a VMware CMDLET, For example, power up a VM guest on ESXI host/Vcenter.

PS C:\> start-VM mvp-sccm02 on ESXI Host.

startvmhostpowershell2startvmhostpowershell3Start VM on Vcenter Host:

startingvumserver.

Vcenter Rcent Taskstarvumserver01Post Successfully Start VM host

startvmcmdlet

* You will see VM host PowerState, Number CPUs , Memory GB status in Powershell Windows

7.  Disconnect from vCenter or ESX
Once finished, it is good practice to disconnect. To do
this type the following command:
Disconnect-VIServer

C:\WINDOWS\system32\
windowspowershell\v1.0\powershell.
exe -PSConsoleFile “C:\Program
Files\VMware\Infrastructure\VSphere
PowerCLI\vim.psc1” -NoExit –Command

Note: The command above is entered as one line

Don’t forget you still must connect to a vCenter Server
or ESX Host so the first command might look like this:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program
Files\VMware\Infrastructure\VSphere PowerCLI\vim.psc1”

-NoExit –Command Connect-VIServer
-Server <vCenterIPAddress> -User
<adminUsername> -Password <password>
Note: The command above is entered as one line

Likewise a PowerShell script named C:\My1stPSscript.ps1 can be called by typing:

C:\WINDOWS\system32\
windowspowershell\v1.0\powershell.
exe -PSConsoleFile “C:\Program
Files\VMware\Infrastructure\VSphere
PowerCLI\vim.psc1” -NoExit –Command
C:\MyFirstPSscript.ps1
Note: The command above is entered as one line

V. Summary

The basics of VMware PowerShell commands has a wealth of information on
PowerShell scripting between the integration of VMware and Microsoft
tools- with with a number of sample scripts.

listvmcmdletpowershell

For example: Let say you need to a VM guest network configuration

PS C:\> get-VMGuestNetworkInterface mvp-sccm01.mvp.local

References:

1. Microsoft PowerShell How Install.
Microsoft PowerShell How Install

2.VMware PowerShell Components Download and
Documentation.
https://www.vmware.com/support/pubs/ps_pubs.html

3. Vmware Powershell Compoenets Install Guide:
https://www.vmware.com/support/developer/windowstoolkit/wintk40/doc/viwin_install.pdf

4. PowerCLI book author has written and introduction to get you up to speed –
http://www.simple-talk.com/sysadmin/powershell/an-introduction-to-powershell-modules/

VI. NetApp PowerShell cmdlets(coming soon!!)

Download the DataONTAP.zip from NetApp site
http://community.netapp.com/t5/Microsoft-Cloud-and-Virtualization-Discussions/Data-ONTAP-PowerShell-Toolkit-3-2/td-p/93081

2. Extract the content folder DataONTAP.

3. Copy the DataONTAP folder to the following location: C:\Windows\System32\WindowsPowerShell\v1.0\Modules

4. Launch the PowerShell window and type the following command. Confirm ‘Yes’ when prompted.

Set-ExecutionPolicy unrestricted

5. Type another command to import the NetApp DataOntap modules in PowerShell:

image

6. Its done! You can confirm by running below command. It will list all the NetAPP cmdlets available

Get-Command -module DataONTAP

Import Vmware CMDLET Modules Guide

Scope: This posting is show overview import Vmware Powershell CMDLET  to manage Vmware environment.

Introduction:

CMDLET Modules have primarily 2 locations on your system:

Default location
%windir%\system32\WindowsPowerShell\Modules this is the location for system wide modules available to any user in the system.

User Level
%USERPROFILE%\Documents\WindowsPowerShell\Modules

C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShel
l\v1.0\Modules\

Each module is stored in a folder where there is a psd1 file that is known as a Module Manifest,powermaifeastmodulesvsphere6

getmodulelisetmodulesvsphere6aThese manifest has the settings for the module and sets the restrictions for it in terms of .Net Framework version, version of PowerShell, files to load, version, copyright, author and many other settings.

This file can load what is called a main module and sub-modules each can either be a psm1 or dll file, in addition they can also be scripts that gets processes. As it can be seen using modules provide great flexibility in terms of formats and structure.

We can also have modules in other locations that can be accessed by the PowerShell session we run in, the locations are defined in the environment variable :$env:PSModulePath

Example

C:\> $env:PSModulePath

* C:\Users\<Vmware Admin User>\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\Modules\

C:\Users\richard\Documents\WindowsPowerShell\modules;C:\Windows\system32\WindowsPowerShell\Modules\

If we want to add another path for PowerShell to look at we just add that path to the current environment variable:

By using the following setting:

$env:psmodulepath = $env:psmodulepath + “;”

To list the modules that are available we use the Get-Module cmdlet withe the -listavailable parameter:

Get-Module -ListAvailable

2.  Download Vmware Powershell Modules:

PowerCLIBook.psd1 – The PowerShell module manifest file, which describes the contents of the module and controls how the module is processed.

PowerCLIBook.psm1 – The PowerShell module file containing the functions which make up the PowerCLIBook module.

DistributedSwitch.psm1 – The PowerShell module file containing the functions which make up the DistributedSwitch nested module, if you like a sub-module of the PowerCLIBook module.

Vmpowerclicmdlet.psm1-The Powersehll module manifest file,The PowerShell module file containing the functions which make up the  module within  VMware.VimAutomation.Core.

I. Import Vmware CMDLET Modules Guide

1. Set Default  the CMDLET Modules Path location by typing the environment variable :$env:PSModulePath

A. Copy CMDLET psm1 files to CMDLET Module User Path (C:\Users\richard\Documents\WindowsPowerShell\modules(Reference CMDLET psm1 download)

powermaifeastB. Open Powershell as Administrator-—> Type; $env:PSModulePath check the default module environment Path Location:

environpathSyntax: PS C:\> $env:PSModulePath

Output Default Environment Path: “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShel
l\v1.0\Modules\”

C. Add User Profile Modules to existing Environment Powershell Path:

Syntax: $env:psmodulepath = $env:psmodulepath + “;”

Example adding user path  C:\Users\richard\Documents\WindowsPowerShell\modules to default Powershell Environment Path:

PS C:\> $env:psmodulepath = $env:psmodulepath + “C:\Users\richard\Documents\WindowsPowerShell\modules;C:\Windows\system32\WindowsPowerShell\Modules\”
PS C:\>custompowershelldefaultenvironmentpowershelldefaultenvironmentOutput Default Environment Path with added custom environment path:

PS C:\> $env:PSModulePath
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShel
l\v1.0\Modules\C:\Users\richard\Documents\WindowsPowerShell\modules;C:\Windows\system32\WindowsPowerShell\Modules\C:\Users\richard\Documents\WindowsPowerShell\modules;C:\Windows\system32\WindowsPowerShell\Modules\

D. List all the Modules—–> Typing:
PS C:\> get-module -ListAvailable

listmodules*Notice you didn’t see none of the below modules there?

PowerCLIBook.psd1 – The PowerShell module manifest file, which describes the contents of the module and controls how the module is processed.

PowerCLIBook.psm1 – The PowerShell module file containing the functions which make up the PowerCLIBook module.

DistributedSwitch.psm1 – The PowerShell module file containing the functions which make up the DistributedSwitch nested module, if you like a sub-module of the PowerCLIBook module.

Vmpowerclicmdlet.psm1-The Powersehll module manifest file,The PowerShell module file containing the functions which make up the  module within  VMware.VimAutomation.Core.

* You much create the exact file path as the psm1 file within the path..

For example—-> All about module must reside under exact folder name :

PowerCLIBook.psd1 – The PowerShell module manifest file, which describes the contents of the module and controls how the module is processed.

  • C:\Users\richard\Documents\WindowsPowerShell\modules\PowerCLIBook<module same as the upper level>

powerclifilepath*Make sure you match module name exact folder structure– module\module folder name\module name(same)

modulespwoershellsCreate folder under Module level —> Module Folder name then put module psd1 under it.

modulesfoldersF: Import Module- Type import-module <Module Folder>

Syntax:
PS C:\> Import-Module PowerCLIBook -Verbose

PowerCLIBook Modules
importmodulepowerclibook
VERBOSE: Importing function ‘Evacuate-VMHost’.
VERBOSE: Importing function ‘Export-Folders’.
VERBOSE: Importing function ‘Export-PermissionsToCSV’.
VERBOSE: Importing function ‘Export-VMLocation’.
VERBOSE: Importing function ‘Export-Xls’.
VERBOSE: Importing function ‘Get-ADUserObject’.
VERBOSE: Importing function ‘Get-AggregationJobs’.
VERBOSE: Importing function ‘Get-ClusterSummary’.
VERBOSE: Importing function ‘Get-DistributedSwitch’.
VERBOSE: Importing function ‘Get-DistributedSwitchCandidate’.
VERBOSE: Importing function ‘Get-DistributedSwitchNetworkAdapter’.
VERBOSE: Importing function ‘Get-DistributedSwitchPortGroup’.
VERBOSE: Importing function ‘Get-DistributedSwitchPrivateVLAN’.
VERBOSE: Importing function ‘Get-FolderPath’.
VERBOSE: Importing function ‘Get-FolderStructure’.
VERBOSE: Importing function ‘Get-IPPool’.
VERBOSE: Importing function ‘Get-LicenseKey’.
VERBOSE: Importing function ‘Get-MissingPortgroups’.
VERBOSE: Importing function ‘Get-Network’.
VERBOSE: Importing function ‘Get-OvfDetails’.
VERBOSE: Importing function ‘Get-SnapshotCreator’.
Vmware VDS Module
importmoduleVDS
PS C:\> Import-Module DistributedSwitch -Verbose
VERBOSE: Importing function ‘Add-DistributedSwitchVMHost’.
VERBOSE: Importing function ‘Get-DistributedSwitch’.
VERBOSE: Importing function ‘Get-DistributedSwitchCandidate’.
VERBOSE: Importing function ‘Get-DistributedSwitchNetworkAdapter’.
VERBOSE: Importing function ‘Get-DistributedSwitchPortGroup’.
VERBOSE: Importing function ‘Get-DistributedSwitchPrivateVLAN’.
VERBOSE: Importing function ‘Get-VMHostPnic’.
VERBOSE: Importing function ‘New-DistributedSwitch’.
VERBOSE: Importing function ‘New-DistributedSwitchNetworkAdapter’.
VERBOSE: Importing function ‘New-DistributedSwitchPortGroup’.
VERBOSE: Importing function ‘New-DistributedSwitchPrivateVLAN’.
VERBOSE: Importing function ‘New-VMHostNetworkAdapter’.
VERBOSE: Importing function ‘Remove-DistributedSwitch’.
VERBOSE: Importing function ‘Remove-DistributedSwitchNetworkAdapter’.
VERBOSE: Importing function ‘Remove-DistributedSwitchPortGroup’.
VERBOSE: Importing function ‘Remove-DistributedSwitchPrivateVLAN’.
VERBOSE: Importing function ‘Remove-DistributedSwitchVMHost’.
VERBOSE: Importing function ‘Set-DistributedSwitch’.
VERBOSE: Importing function ‘Set-DistributedSwitchNetworkAdapter’.
VERBOSE: Importing function ‘Set-DistributedSwitchPortGroup’.
VERBOSE: Importing function ‘Set-DistributedSwitchVMHost’.

InfraTools
importmoduleinfratools
PS C:\> Import-Module infraTools -Verbose
VERBOSE: Importing function ‘Get-SyslogInfo’.
VERBOSE: Importing function ‘Get-VMCreationDate’.
VERBOSE: Importing function ‘Get-VMdisk’.
VERBOSE: Importing function ‘Get-VMEvents’.
VERBOSE: Importing function ‘Get-VMStat’.
VERBOSE: Importing function ‘Set-VMdisk’.

G: List Module Recently Imported:

listednewlyimportedmodulesIII. References:

A. PowerCLIBook
http://www.powerclibook.com/?p=137B. Windows Powershell Moduleshttps://msdn.microsoft.com/en-us/library/dd878324%28v=vs.85%29.aspx

B. Vmware PowerCLI Blog
http://blogs.vmware.com/PowerCLI/tag/powercli-modules

C. Infra Tools Modules
https://psvmware.wordpress.com/

 

How To Build OS Template In Vmware Vcenter-

This posting will provide overview in successfully deploying VM host from a template in leverage MS System Preparation Tool 3.1.4.

There are 2 sections, 1st cover to how create a clone of VM host OS image via System Preparation Tool 3.1.4. The 2nd section will show how to take newly create System Prep VM Host OS image and convert to it a VMware Vcenter template and deploy it in  the Mware Vcenter environment.

Prerequisites requirements: Windows 7, 8, Windows Server 2008, 2012 and 2016 OS already installed OS image,  MS System Preparation Tool(Sysprep) 3.14,  and VMware Vcenter Server 

What is System Preparation Tool (Sysprep)?
System Preparation Tools is MS tool to allow System Administrators to clone in a automate method deployment of  all Windows Operating Systems. (Windows Workstation OS 7, 8, 10 and Windows Server 2008 R2,, 2012 R2  and Window 2016 OS.

Windows 2012 Server

syspropob

 

syspre6

      Windows 2016 Server. 

20167

20168

Great VMware Tutorial- Cloning and Templates in vSphere-  

 

Will not cover Windows 2003 or Windows XP due to both products are EOL. 

Here is an example image what system prep tool 3.1.4 looks like.  Once you have performed the initial setup steps on a single computer, you can run the Sysprep tool to prepare the sample computer for cloning and automate the deployment on other computers. It can be found in the \Windows\System32\sysprep folder.

 

 

System Preparation Tool – Sysprep

You can use Sysprep along with other deployment tools to install Windows Operating systems onto new infrastructure (bare metal hardware or Virtualize hardware). It prepares a computer for disk imaging or delivery to a customer by configuring the computer to create a new computer security identifier (SID) when the computer is restarted. In addition, the Sysprep tool cleans up user-specific and computer-specific settings and data that must not be copied to a destination computer.

Once the system is prepared with the applications the configurations we want, we navigate to C:\Windows\System32\sysprep and then open the sysprep tool.

Select ‘Enter System Out of Box Experience’ select the ‘Generalize’ option and then select ‘Reboot’.

System Preparation Tool (Sysprep)

 

This process will generalize the Windows installation and allow you to capture a system image of this computer so that it can be installed on other computers.

When sysprep is finished, shutdown the computer.

Now the system image is ready to be captured. We can perform this task from another system partition or from within Windows preinstallation environment.

The 2nd section will illustrate how to convert newly created VM with syspreps to incorporate to How To Deploy Virtual Machine From A Template in Vsphere.

deployfromtemplate

   Here is example of  Sysprep Out Of Box Configuration – Window 2012 R2- 

1. Prompt to Input System Time and Region. 

syspre2

 2,  Click  Accept EUL.

syspre3

3. Input Administrator Password. 

syspre4

4. Click- Insert – Control -Alt -Delete. 

syspre5

5. Log into newly deploy Windows 2012R2 from Template. using password set in the step 3. 

syspre6

Great VMware Tutorial- Cloning and Templates in vSphere-  

 

How to Create VMware Templates

VMware vCenter Server allows you to create templates from existing virtual machines. You can use templates to reduce the amount of time spent building and implementing new servers, cutting down the provisioning process to just a few hours.

vCenter Server uses one of two methods to build templates. The first method, Clone to Template, duplicates a virtual machine and changes it to the template format. Unlike Convert to Template, which I’ll cover in just a moment, Clone to Template leaves the original virtual machine intact.uring the cloning process, you’ll have the option to change the format of the virtual disk(s). You can either configure the disk to fill all of the space in the datastore (thus enabling the template to maintain the same level of performance as the source VM), or use the thin provisioned format to compress the disk space so that the template uses only as much of the datastore as it needs.

Of course, when vCenter clones the source virtual machine, it doesn’t just duplicate the virtual disks, but also creates a copy of the .vmx file. The .vmx file holds the data used to configure the VM. Thus, before you run Clone to Template, you should remove any unwanted settings from the .vmx file associated with the source VM.

Convert to Template, the other method used to create templates in vCenter, is much faster than Clone to Template, because it doesn’t create a duplicate of the source VM; instead, it just changes the VM to the template format. Convert to Template is more flexible than Clone to Template because you can change the template back to a virtual machine at any time. For example, software installed to templates created through Clone to Template can’t be updated. With Convert to Template, however, you can temporarily change the template to a virtual machine and install updates to the software, then change the VM back to template when done.

Preparing for Template Creation

Before creating a template in vCenter, you’ll need to install Sysprep to VMware if you intend to clone or convert Windows-based virtual machines. Each release of Windows (including service packs) requires its own version of Sysprep; you can find the appropriate files on the operating system CD/DVD or on the Microsoft Download Center website. Find and double-click deploy.cab, and then extract the contents of the compressed file to the following location:  %allusersprofile%\vmware\vmware virtualcenter\sysprep

If you’re running Windows Server 2003 or below, extract the contents to: %allusersprofile%\application data\vmware\vmware virtualcenter\sysprep

There are also a few things to keep in mind before you create your source virtual machine (the virtual machine on which the template will be based). Components like Active Directory and Microsoft SQL Server should be excluded from the template, as these can interfere with the template creation process or cause problems after the fact. Also, if you’re running VMware Infrastructure 3.5 or later, you can perform a hot clone of a virtual machine using the Clone to Template method. Hot cloning enables you to keep the source VM active during the cloning and conversion process.

Once you’ve installed Sysprep and created the source virtual machine, you can begin building templates.

Creating a Template with Clone to Template

  1. Right-click the source virtual machine. Point to “Template,” then select “Clone to Template” from the context menu.
  2. Create a name for the template and then choose an Inventory location from the folder list. Click “Next.”
  3. Select the ESX host or cluster where the template should be stored. Click “Next.”
  4. Select a datastore with enough available space to accommodate the template. Click “Next.”
  5. Click “Same as Source” to use the same disk format as the source VM; click “Thin Provisioned” to save space on the datastore; click “Thick” to reserve all of the datastore space for the virtual hard disk. If you select “Thin Provisioned,” make sure to allocate the virtual disk to a VMFS3+ datastore. Click “Next.”
  6. Review your selections on the Ready to Complete screen. Click “Finish” to create the new template in VMware vCenter Server.

Create a Template with Convert to Template

  1. Power off the source VM. Right-click the virtual machine, and then point to “Template.”
  2. Click “Convert to Template.” Select “Home.” Go to VMs and Templates view to locate the new template.
  3. Right-click the template and then click “Convert to Virtual Machine” to return the template to its original state whenever necessary.

You can also create new templates from existing templates. Right-click the source template and then click “Clone” to begin the duplication process. The steps in the wizard are identical to those in Clone to Template.

Create a Virtual Machine from a Template

After you finish creating a template, you can run the Deploy Template Wizard to create a new virtual machine.

  1. Switch to VM and Templates view. Right-click the template and select “Deploy Virtual Machine from This Template” from the context menu.
  2. Name the virtual machine and select a folder location. Click “Next.”
  3. Select the ESX host and/or cluster on which the VM will run. Click “Next.”
  4. Choose which resource pool the new virtual machine will use. Click “Next.”
  5. Select which datastore or datastores will accommodate the virtual machine. Click “Next.”
  6. Choose the appropriate disk format and then click “Next.”
  7. Click “Do Not Customize,” “Customize Using the Customization Wizard,” or “Customize Using an Existing Customization Specification,” depending on your preferences. You won’t see this screen if you didn’t load Sysprep into vCenter. If you selected the second or third option, follow the on-screen instructions to configure the template.

(Note: If the OS installed to the source virtual machine requires an OEM product code, select option two and then enter the information into the appropriate field when prompted.)

  1. Click “Edit Virtual Hardware” to make changes to the VM configuration, if necessary. Click “Finish” to deploy the new virtual machine.

9. Power on VM to check if Sysprep is working.

 

Reference

System Preparation Tool 3.1.4
https://technet.microsoft.com/en-us/library/cc721940(v=ws.10).aspx

Deploy a Virtual Machine from a Template in the vSphere Client
https://pubs.vmware.com/vsphere-50/topic/com.vmware.vsphere.vm_admin.doc_50/GUID-9062F225-E01B-42BA-8AFB-8EA4069068FE.html

MS Download – Operating Systems
http://windows.microsoft.com/en-US/windows/downloads

 

 

Vmware Vsphere vCenter 5.5 Install Guide On Windows 2012 R2.

Vmware Vsphere vCenter  5.5 Install Guide On Windows 2012 R2.

vcenter2

1.1      Target Audience/Purpose/Scope:

This document is targeted installation of  Vmwae Vsphere 5.5 vCenter Server.

 The purpose and scope in implementing vCenter 5.5 Server to leverage

  • Storage VMotion,
  • VMware High Availability (VMHA),
  • VMware Distributed Resource Scheduler (DRS).
  • Link to datacenter Vcenter-

1.2   Scope of the document:

  • Cover only Vcenter Server Core Installation.
  • Linked Mode to bridge 2 Datacenter Vcenter

1.3      Prerequisite requirements

  1. Download VMware-VIMSetup-all-5.5.0-1378901-20131001 from VMware download
  2. Windows 2012 R2 OS
  3. Min CPU, RAM and Disk requirements
  4. CPU x 2, RAM 2G to 4G, and Disk 50 G
  5. vcenter Host DNS -FQDN and AD Membership Registered to both AD and DNS. i.e

VMware Vsphere vCenter 5.5 Install Guide On Windows 2012 R2-Click Here Download

vmware_vCenter5.5_install_Guide

 

 

Tutorial Video by VMware KB TB

Reference

Installing Vcenter 5.5 on Windows 2012 R2
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2061000