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