PSScripter's Posts

This seems to work:   Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster -name "XXXXXXXXXXX" | Get-VMHost $cred = Get-Credential $cmd = "mv /vmfs/volumes/INF03-PMAX-NonProd-DS01/ucs-tool-esxi_... See more...
This seems to work:   Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster -name "XXXXXXXXXXX" | Get-VMHost $cred = Get-Credential $cmd = "mv /vmfs/volumes/INF03-PMAX-NonProd-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp" $cmd1 = "python /opt/ucs_tool_esxi/ucs_host_inventory.py" $arguments = @{ 'VIBNAME' = '/tmp/ucs-tool-esxi_1.2.1-1OEM.zip' } foreach ($esx in $hosts) { Get-VMHost $esx | Get-VMHostService | Where-Object { $_.Key -eq "TSM-SSH" } | Start-VMHostService $session = New-SSHSession -ComputerName $esx -Credential $cred -AcceptKey Invoke-SSHCommand -SSHSession $session -Command $cmd $esxcli = Get-EsxCli -VMHost $esx $esxcli.software.vib.install("/tmp/ucs-tool-esxi_1.2.1-1OEM.zip") Invoke-SSHCommand -SSHSession $session -Command $cmd1 Remove-SSHSession -SSHSession $session | Out-Null }  
I'm still trying to get this working correctly. Here is my latest, and the error I am getting:   Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster -name "XXXXXXXXXXX" | Get-VMHost $cred = Get-... See more...
I'm still trying to get this working correctly. Here is my latest, and the error I am getting:   Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster -name "XXXXXXXXXXX" | Get-VMHost $cred = Get-Credential $cmd = "mv /vmfs/volumes/INF03-PMAX-NonProd-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp" $cmd1 = "python /opt/ucs_tool_esxi/ucs_host_inventory.py" $arguments = @{ 'VIBURL' = '/tmp/ucs-tool-esxi_1.2.1-1OEM.zip' } foreach ($esx in $hosts) { # Get-VMHost $esx | Get-VMHostService | Where-Object { $_.Key -eq "TSM-SSH" } | Start-VMHostService $session = New-SSHSession -ComputerName $esx -Credential $cred -AcceptKey Invoke-SSHCommand -SSHSession $session -Command $cmd $esxcli = Get-EsxCli -VMHost $esx $esxcli.software.component.apply.Invoke($arguments) Invoke-SSHCommand -SSHSession $session -Command $cmd1 Remove-SSHSession -SSHSession $session | Out-Null } The copy seems to work, but the esxcli command is failing with this:   MethodInvocationException: C:\Temp\vSphere\Install-UCSTools.ps1:19 Line | 19 | $esxcli.software.component.apply.Invoke($arguments) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Exception calling "Invoke" with "1" argument(s): "A specified parameter was not correct: argument[1]"   Any thoughts on how I can get this working?   Thank You.
Here is what I came up with, I have not used it yet..but I think it will work     Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster "XXXXXXXXXX" | Get-VMHost $cred = Get-Credential $cmd = ... See more...
Here is what I came up with, I have not used it yet..but I think it will work     Connect-VIServer 'XXXXXXXXXXXXX' $hosts = Get-Cluster "XXXXXXXXXX" | Get-VMHost $cred = Get-Credential $cmd = "mv /vmfs/volumes/INF03-PMAX-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp" $cmd1 = "python /opt/ucs_tool_esxi/ucs_host_inventory.py" foreach ($host in $hosts) { Get-VMHost $host | Get-VMHostService | Where-Object { $_.Key -eq "TSM-SSH" } | Start-VMHostService $session = New-SSHSession -ComputerName $host -Credential $cred -AcceptKey Invoke-SSHCommand -SSHSession $session -Command $cmd Get-esxcli software component apply -d /tmp/ucs-tool-esxi_1.2.1-1OEM.zip Invoke-SSHCommand -SSHSession $session -Command $cmd1 Remove-SSHSession -SSHSession $session | Out-Null }     Any thoughts on that piece of work lol?
Thanks, Ill check out Posh-SSH
Hello, I need to run the following commands against 2 clusters of hosts, 26 in total, all contained in 1 VC:   mv /vmfs/volumes/WB01-INF03-PMAX-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp esxcli softw... See more...
Hello, I need to run the following commands against 2 clusters of hosts, 26 in total, all contained in 1 VC:   mv /vmfs/volumes/WB01-INF03-PMAX-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp esxcli software component apply -d /tmp/ucs-tool-esxi_1.2.1-1OEM.zip python /opt/ucs_tool_esxi/ucs_host_inventory.py   Can anyone point me in the right direction to do this in PS? I dont want to ssh into all of the hosts. Thank You!
That is exactly what I was looking for, thanks LucD.
Hi folks, I need to get all the AA rules for a bunch of VMs. This here is the format I was looking for, can anyone modify this so it fills in the "VMNames" column? As it is now it outputs everythin... See more...
Hi folks, I need to get all the AA rules for a bunch of VMs. This here is the format I was looking for, can anyone modify this so it fills in the "VMNames" column? As it is now it outputs everything except that column has System.Object[] in it , instead of the VMs that comprise the rule Get-DrsRule -Cluster $cluster | select Cluster,Name,KeepTogether,Enabled, @{N="VMnames";E={ $_.Vmids|%{(get-view -id $_).name}}} | Export-Excel c:\temp\AArules-myservers.xlsx -AutoFilter -AutoSize  Thanks!
PS, I DID tweak the script slightly to add virtualcenter colomun: $vc = (Get-Content C:\temp\ITScript\vSphere\vcs.txt) # # Get a list of all VMs in connected vCenter # foreach ($v in $vc){ Connect-V... See more...
PS, I DID tweak the script slightly to add virtualcenter colomun: $vc = (Get-Content C:\temp\ITScript\vSphere\vcs.txt) # # Get a list of all VMs in connected vCenter # foreach ($v in $vc){ Connect-VIServer $v } $clusters = (Get-Content C:\temp\ITScript\vSphere\clusters.txt) $allVM = Get-Cluster $clusters | Get-VM | Sort-Object -Property Name # # Get all Categories & Tags # $assigned = $allVM | Get-TagAssignment $ordered = $assigned.Tag.Category.Name | Sort-Object -Unique # # Cycle through all VMs and associate the Categories & Tags to those with # Categories & Tags assigned. # $allVM | ForEach-Object -Process { $obj = [ordered]@{ VM = $_.Name PowerState = $_.PowerState Notes = $_.Notes Guest = $_.Guest.OSFullName NumCpu = $_.NumCpu CoresPerSocket = $_.CoresPerSocket MemoryMB = $_.MemoryMB MemoryGB = $_.MemoryGB VMHostId = $_.VMHostId VMHost = $_.VMHost.Name Folder = $_.Folder.Name Version = $_.Version GuestId = $_.GuestId UsedSpaceGB = $_.UsedSpaceGB ProvisionedSpaceGB = $_.ProvisionedSpaceGB VirtualCenter = $_.Uid.Split(":")[0].Split("@")[1] } # Create a column header using the Categories. $ordered | ForEach-Object -Process { $obj.Add($_, '') } $assigned | Where-Object { $_.Entity.Name -eq $obj.VM } | Group-Object -Property { $_.Tag.Category.Name } | ForEach-Object -Process { $obj[$_.Name] = $_.Group.Tag.Name -join '|' } New-Object -TypeName PSObject -Property $obj } | Export-Csv -Path "C:\temp\VMTag-export.csv" -NoTypeInformation -UseCulture    
Hi All, Using this version: https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-export-tags-category-all-other-default-columns/m-p/2944629/highlight/true#M109637   It works reall... See more...
Hi All, Using this version: https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-export-tags-category-all-other-default-columns/m-p/2944629/highlight/true#M109637   It works really well. One question I have,  I have it connecting to 6 different virtual centers. It gives me output on everything, except 1 of the VCs I get this error, I guess on every VM, so it ends up taking the script ~12 hours to run or something. If I take that VC out, it completes MUCH faster. but that 1 VC gets no tag output either, all blanks   Here is the error: Get-TagAssignment : 2/6/2023 7:26:44 AM Get-TagAssignment com.vmware.vapi.std.errors.unauthenticated {'messages': [com.vmware.vapi.std.localizable_message {'id': com.vmware.vapi.endpoint.method.authentication.required, 'default_message': Authentication required., 'args': [], 'params': , 'localized':}], 'data': , 'error_type': UNAUTHENTICATED, 'challenge': Basic realm="VAPI endpoint",SIGN realm=ad091aa8c019850e8e945f742dcc46afeb8211a6,service="VAPI endpoint",sts="https://virtualcenter"}. At C:\temp\ITScript\vSphere\vms\Get-VMTags2.ps1:13 char:22 + $assigned = $allVM | Get-TagAssignment + ~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-TagAssignment], CisException + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTagAssi gnment.Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTagAssignment   Any ideas why that 1 virtual center would give these errors?   Thank you.  
Great, Ill check those out, thanks LucD
I have been using this script which I also found on this site, that I modified to add all of my own tag categories. I was just wondering if this can be made so it just gets all of the tag categories,... See more...
I have been using this script which I also found on this site, that I modified to add all of my own tag categories. I was just wondering if this can be made so it just gets all of the tag categories, rather than listing them all like this. I dont have them all listed, just some, but now I think I want to get them all, and I could do that by adding them manually, but a script would be better. $report = @() foreach($vm in Get-View -ViewType Virtualmachine){ $vms = "" | Select-Object VMName,VMState,AppVersion,ServerType,Application,Region,Environment,InfraOwner $vms.VMName = $vm.Name $vms.VMState = $vm.summary.runtime.powerState $vms.AppVersion = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "AppVersion").Tag.Name $vms.ServerType = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "Server Type").Tag.Name $vms.Application = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "Application").Tag.Name $vms.Region = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "Region").Tag.Name $vms.Environment = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "Environment").Tag.Name $vms.InfraOwner = (Get-TagAssignment -Entity (Get-VIObjectByVIView -VIView $vm) -Category "Infrastructure Owner").Tag.Name $report += $vms } $report | Export-Excel C:\Temp\VMTags.xlsx   Thanks!  
Is there anyway that script can be modified to output each tag in its own column in Excel (rather then separated by |), and add the Tag Category as a header in the file so you can then filter on tag ... See more...
Is there anyway that script can be modified to output each tag in its own column in Excel (rather then separated by |), and add the Tag Category as a header in the file so you can then filter on tag category in the report? Thank you
yes I was tried to remove that post because my version to check the status does not actually work I was looking to tweak it so I can check the status, but also get 1 entry for each DS.
How would one tweak this script to just show the status of this setting, and not actually change it Thank you!
yup it was in some ancient documentation. I have it in my VMware VIX directory:   Directory of C:\Program Files (x86)\VMware 01/22/2023 08:50 AM <DIR> . 01/22/2023 08:50 AM <DIR> .. 01/21/2023 0... See more...
yup it was in some ancient documentation. I have it in my VMware VIX directory:   Directory of C:\Program Files (x86)\VMware 01/22/2023 08:50 AM <DIR> . 01/22/2023 08:50 AM <DIR> .. 01/21/2023 02:07 PM <DIR> VMware Remote Console 01/22/2023 08:50 AM <DIR> VMware VIX 0 File(s) 0 bytes 4 Dir(s) 94,380,818,432 bytes free C:\Program Files (x86)\VMware>cd "VMware VIX" C:\Program Files (x86)\VMware\VMware VIX>dir Volume in drive C has no label. Volume Serial Number is 049F-3D87 Directory of C:\Program Files (x86)\VMware\VMware VIX 01/22/2023 08:50 AM <DIR> . 01/22/2023 08:50 AM <DIR> .. 02/24/2017 03:02 AM 25,214 arp.ico 01/22/2023 08:50 AM <DIR> doc 02/24/2017 03:01 AM 25,294 eula.rtf 02/24/2017 03:02 AM 114,535 open_source_licenses.txt 01/22/2023 08:50 AM <DIR> Samples 02/24/2017 03:01 AM 476,573 vix-perl.zip 02/24/2017 03:01 AM 46,920 vix.h 02/24/2017 03:01 AM 7,731,192 Vix64AllProducts.lib 02/24/2017 03:01 AM 7,731,192 Vix64AllProductsd.lib 02/24/2017 03:01 AM 559,104 Vix64AllProductsDyn.dll 02/24/2017 03:01 AM 28,852 Vix64AllProductsDyn.lib 02/24/2017 03:01 AM 6,942,872 VixAllProducts.lib 02/24/2017 03:01 AM 6,942,872 VixAllProductsd.lib 02/24/2017 03:01 AM 437,760 VixAllProductsDyn.dll 02/24/2017 03:01 AM 29,384 VixAllProductsDyn.lib 01/22/2023 08:50 AM <DIR> VixCOM 02/24/2017 03:01 AM 536,576 VixCOM.dll 02/24/2017 03:01 AM 674,816 VixCOM64.dll 02/24/2017 03:02 AM 1,810 vixwrapper-config.txt 02/24/2017 03:01 AM 462,336 vmrun.exe 02/24/2017 03:01 AM 29,909 vm_basic_types.h 01/22/2023 08:50 AM <DIR> Workstation-12.0.0 18 File(s) 32,797,211 bytes 6 Dir(s) 94,380,158,976 bytes free C:\Program Files (x86)\VMware\VMware VIX>
Thanks for clarifying. I saw vmrun had a -T esx switch so thought it was possible, but either way without vmrc I dont think it works.
Thanks for that LucD.   You can pass commands to VMs using the VIX Vmware  api, using vmrun. It looks like the esx hosts need to have the vmware remote console service running though, so its out fo... See more...
Thanks for that LucD.   You can pass commands to VMs using the VIX Vmware  api, using vmrun. It looks like the esx hosts need to have the vmware remote console service running though, so its out for me
Hello, Wondering if the above command creates a profile in Windows?   Another question....is there anyway to pass a command to a VM through vcenter/esx, in such a way to not create a profile?   ... See more...
Hello, Wondering if the above command creates a profile in Windows?   Another question....is there anyway to pass a command to a VM through vcenter/esx, in such a way to not create a profile?   Thanks!
Is there anyway to script Enabling/Disabling Clustered VMDK Support on a datastore? Thanks!
Hello, I need to do what the title says. I asked this question to ChatGPT, and this is the answer returned. My question is, does this look like its valid to anyone? I was going to try it on a test ... See more...
Hello, I need to do what the title says. I asked this question to ChatGPT, and this is the answer returned. My question is, does this look like its valid to anyone? I was going to try it on a test DS, but curious on thought first.   # Get all datastores in the cluster $datastores = Get-Datastore -Location (Get-Cluster) # Loop through each datastore and enable clustered VMDK support foreach ($datastore in $datastores) { $spec = New-Object VMware.Vim.HostDatastoreSystemVStorageObjectSpec $spec.operation = "enable" $spec.vStorageObject = $datastore.ExtensionData.Info.VStorageSupportObject $task = $datastore.ExtensionData.ConfigManager.DatastoreSystem.UpdateVStorageObject($spec) $task.WaitForCompletion() }   Thanks!