Archive for year: 2014
VMware PowerCLI script to add storage and VLAN’s
/in PowerShell, VMware/by Jeroen van RoonWhen deploying multiple VMware hosts you can use the Template feature in vSphere. If you’re not licenced to use the template feature in vSphere you can use the VMware PowerCLI PowerShell commands to quickly add the strorage and the networks.
First thing you got to do is connect to the host:
- Connect-VIServer -Server esx.jvr.local
To add VLAN’s to a vSwitch use the following command:
- get-vmhost -name esx.jvr.local | Get-VirtualSwitch -name vSwitch0 | new-VirtualPortGroup -name “LAN” -vlanid 0
- get-vmhost -name esx.jvr.local | Get-VirtualSwitch -name vSwitch0 | new-VirtualPortGroup -name “PVS” -vlanid 2310
To add NFS storage use the following commands:
- get-vmhost -name esx.jvr.local | New-Datastore -Nfs -Name ESX1 -Path /NAS_ESX1 -NfsHost 10.10.10.50
This can also be done at the cluster level. The following command’s can be used:
- Get-Cluster “CLUSTER_1” | Get-VMHost | Get-VirtualSwitch -name vSwitch1 | New-VirtualPortGroup -name “PVS” -VLanId 2310
- Get-Cluster “CLUSTER_1” | Get-VMHost | Get-VirtualSwitch -name vSwitch1 | New-VirtualPortGroup -name “HB” -VLanId 2309
Basic App-V 5 Client PowerShell Commands
/in App-V, Microsoft, PowerShell/by Jeroen van RoonThese PowerShell commands should be run on an App-V 5 Client computer. The first step is importing the App-V module, as it’s not imported by default.
- Import-Module AppvClient
This must be run to import the module to allow PowerShell to run PowerShell cmdlets for the App-V 5 Client.
- Get-Command -Module Appvclient
This gets a list of PowerShell commands for the App-V Client module.
- Add-AppvPublishingServer -Name [Name of App-V Publishing Server] -URL [URL]
Adds the specified App-V 5 Publishing Server to the App-V 5 Client.
- Sync-AppvPublishingServer -Name [Name of App-V Publishing Server]
Syncs the App-V 5 Client’s apps with the App-V 5 Publishing Server.
- Add-AppvClientPackage \\Servername\Sharename\Appfilename.appv
Adds a package to the local App-V 5 Client.
- Add-AppvClientPackage \\Servername\Sharename\Appfilename.appv | Publish-AppvClientPackage -Global
Invoke PowerShell commands to multiple servers at the same time
/in Microsoft, PowerShell, Windows Server/by Jeroen van RoonOne of the best things of PowerShell is that you can invoke commands to multiple servers at once. This can save a lot of time when implementing new features or troubleshooting errors. The PowerShell Command that makes this possible is:
- Invoke-Command -ComputerName [Computername1], [Computername1] -command {[PowerShell Command here]}
In this example i have installed the Windows Clustering Feature on three different servers with the following command:
- Invoke-Command -ComputerName 2012R2-AS07, 2012R2-AS08, 2012R2-AS09 -command {Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools}
In this example i have added a Firewall rule on three different servers with the following command:
- Invoke-Command -Computername 2012R2-AS07, 2012R2-AS08, 2012R2-AS09 -command {New-NetFirewallRule -DisplayName “SQL Server Browser Service” -Direction inbound –LocalPort 1434 -Protocol TCP -Action Allow -Profile Domain}
In this example i have specified the sxs folder:
- Install-WindowsFeature –name NET-Framework-Core -source \\[Servername]\sxs -ComputerName 2012R2-AS07