Quantcast
Channel: VMware Communities : Discussion List - VMware PowerCLI
Viewing all 14549 articles
Browse latest View live

Get memory for virtual machines in order of imported csv

$
0
0

I recently exported the names of all of our virtual machines, then organized over 400 of them in different groups. I neglected to also export the memory so I'm trying to import an csv get the memory and export that to a csv. That way I can just copy and paste the memory from one spreadsheet to another. I think I'm missing something simple but I can't see it I am trying this

 

$servers=Import-Csv C:\Users\sjesse\Desktop\sdcvms.csv

$vms=@()

foreach ($server in $servers)

{

 

    $vm=Get-VM -Name $server.Name select Name, Description, PowerState, NumCpu, MemoryGB

    $vms+=$vm

}

 

$vms | Export-Csv "C:\vms.csv" –NoTypeInformation

 

and I keep geting this error

 

VM with name '<name of the server>' was not found using the specified filter(s).

 

The name in the error is the exact name I see in vcenter, and was an exported by using get-vm to get all of the virtual machine names using this.

 

Get-VM | select Name | Export-Csv -path “c:\vminventory.csv” –NoTypeInformation

 

so I can't see why I can't find the VMs.


What are the ScheduledHardwareUpgradeInfo.UpgradePolicy Options

$
0
0

Hey All--

 

Wondering if anyone has some info on this.  Looking to better understand the ScheduledHardwareUpgradeInfo.UpgradePolicy options.  What each does, and long-term impacts.  Hoping folks can chime in here.

 

For passers-by who aren't familiar with what I'm referring to, I'm looking to better understand the various ways of upgrading the VM Hardware.  In the past, you always had to power the VM off before you could upgrade the hardware, or schedule it with VM.  Later they gave you the "Schedule Hardware Upgrade" option within the webclient which waiting until the VM was powered off then back on. Now it seems in the webclient, there's a new(er) option when editing a VM's settings for "Upgrade > Schedule VM Compatibility" (with a sub option to only upgrade on GuestOS shutdown).  Selecting this later option (edit vm settings > upgrade > schedule vm compatibility w/o sub-option for guestos shutdown), appear to upgrade the VM Hardware now at reboot rather than full shutdown/poweron.

 

So now comes the questions...

 

When doing this via PowerCli, I understand there are three (if more feel free to add) options for the 'ScheduledHardwareUpgradeInfo.UpgradePolicy' ReconfigureVM method.  'Always', 'Never', and 'onSoftPowerOff'.  What I'm unclear on, is if I use this method with 'Always', to set the version key and reconfigure the VM, does this mean that from now on, every time the VM reboots, it will upgrade hardware if an upgrade is available?  Or, is this a one-time shot like you'd get from doing the same thing with the webclient?  If this isn't a one-time shot and setting the UpgradePolicy to 'Always' actually does mean always after reboot if available, then the final question is, how can I achieve the same result as the webclient way and not impact future version upgrades being forced?

 

Thanks!

VM report daily

$
0
0

Hello, I would like something like this:

 

$VMS = get-vm
$report = @()
foreach ($vm in $VMS) {
$row = "" | select  "VM","DNS Name",PowerState,CPU,Memory,DiskProvisioned,DiskUsed,Cluster,Environment
$row."VM" = $vm.Name
$row."DNS Name" = $vm.Guest.get_HostName()
$row.PowerState = $vm.PowerState
$row.CPU = $vm.NumCPU 
$row.Memory = $vm.MemoryGb
$row.DiskProvisioned = $vm.ProvisionedSpaceGB
$row.DiskUsed = [Math]::Round($vm.UsedSpaceGB,2)
$row.Cluster = ($vm | get-cluster).Name
$row.Environment = "PROD"
$report += $row


 }


 $report |Export-Csv C:\Users\gemela\Desktop\report.csv -NoTypeInformation

 

Also add info like: Version, Vmtools status and IP,

I would like to set this report to create new file (with date) every day (append) , example: report_2018_02_16.csv

 

Thanks for support

sum the value in the colume

$
0
0

This is my query:

Get-Datastore | where{$_.ExtensionData.summary.multiplehostAccess} | where {$_.name -like  "XIO*"}

 

i am getting this output. can any one guide me how i can sum the value for both FreeSpaceGB and CapacityGB.

 

and show them separably, my basic goal is to sum and have percentage of both columes

Port needed for PowerCLI

$
0
0

Hi,

 

I would like to know, what are the ports used by PowerCLI remote server to connect to vCenter or ESXi ?

 

Thanks

Madhusudan

PowerCLI snapshot reports

$
0
0

I'm struggling with two scripts that I would like to combine, but need assistance. Essentially one outputs html (this i need), the other has information that i also need:

VMSnapNameDaysOldCreatorSizeGBCreated

Description

 

 

Here are the scripts:

# HTML formatting

$a = "<style>"

$a = $a + "BODY{background-color:white;}"

$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"

$a = $a + "TH{border-width: 1px;padding: 5px;border-style: solid;border-color: black;foreground-color: black;background-color: LightBlue}"

$a = $a + "TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;foreground-color: black;background-color: white}"

$a = $a + "</style>"

 

 

# Main section of check

Write-Host "Checking VMs for for snapshots"

$date = get-date

$datefile = get-date -uformat '%m-%d-%Y-%H%M%S'

$filename = "C:\Snaps" + $datefile + ".htm"

 

 

# Get list of VMs with snapshots

# Note:  It may take some time for the  Get-VM cmdlet to enumerate VMs in larger environments

$ss = Get-vm | Get-Snapshot

Write-Host "   Complete" -ForegroundColor Green

Write-Host "Generating VM snapshot report"

#$ss | Select-Object vm, name, description, powerstate | ConvertTo-HTML -head $a -body "<H2>VM Snapshot Report</H2>"| Out-File $filename

$ss | Select-Object vm, name, description | ConvertTo-HTML -head $a -body "<H2>VM Snapshot Report</H2>"| Out-File $filename

Write-Host "   Complete" -ForegroundColor Green

Write-Host "Your snapshot report has been saved to:" $filename

 

Other script:

# Load PowerCLI Module

 

  if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {

 

  . “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”

 

  }

 

function Get-SnapshotSummary {

 

  param(

 

  $InputObject = $null

 

  )

 

    PROCESS {

 

  if ($InputObject -and $_) {

 

  throw 'ParameterBinderStrings\AmbiguousParameterSet'

 

  break

 

  } elseif ($InputObject) {

 

 

  $InputObject

 

  } elseif ($_) {

 

  $mySnaps = @()

 

  foreach ($snap in $_){

 

  $SnapshotInfo = Get-SnapshotExtra $snap

 

  $mySnaps += $SnapshotInfo

 

  }

 

  $mySnaps | Select VM, @{N="SnapName";E={[System.Web.HttpUtility]::UrlDecode($_.Name)}}, @{N="DaysOld";E={((Get-Date) - $_.Created).Days}}, Creator, @{N="SizeGB";E={$_.SizeGB -as [int]}}, Created, Description -ErrorAction SilentlyContinue | Sort DaysOld

 

  } else {

 

  throw 'ParameterBinderStrings\InputObjectNotBound'

 

  }

 

  }

 

}

 

function Get-SnapshotTree{

 

  param($tree, $target)

 

  $found = $null

 

  foreach($elem in $tree){

 

  if($elem.Snapshot.Value -eq $target.Value){

 

  $found = $elem

 

  continue

 

  }

powershell vm cli not running as a CGI

$
0
0

I am running pwsh (PowerShell v6.1.0-preview.2) on Ubuntu 16.04.

   VMware PowerCLI 10.1.0 build 8346946

   VMware Cis Core PowerCLI Component PowerCLI Component 10.1 build 8377811

   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 10.1 build 8344055

 

 

 

When I run my powerCLI script from a shell it runs perfectly, but when I run it as a CGI the vmware module aborts.

 

apache2/error.log says:

 

AH01215: Connect-VIServer : The type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManager' threw an exception.: /var/www/html/vm.ps1

AH01215: At /var/www/html/vm.ps1:62 char:7: /var/www/html/vm.ps1

AH01215: + if(Connect-VIServer -Server $vmSphere -user $vmSphereUser -passwor ...: /var/www/html/vm.ps1

AH01215: +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~: /var/www/html/vm.ps1

AH01215: + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], TypeInitializationException: /var/www/html/vm.ps1

AH01215: + FullyQualifiedErrorId : System.TypeInitializationException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer: /var/www/html/vm.ps1

AH01215:  : /var/www/html/vm.ps1

 

 

 

syslog contains the errors in the attached errors.txt file.

Connect-HVserver error

$
0
0

Hi all,

 

I'm getting this error when I try to connect with the Horizon Api :

 

Connect-HVServer : The request channel timed out while waiting for a reply

after 00:01:39.9989768. Increase the timeout value passed to the call to

Request or increase the SendTimeout value on the Binding. The time allotted to

this operation may have been a portion of a longer timeout.

At D:\ListadoVDD.ps1:53 char:1

+ Connect-HVServer -server myserver.fqdn.corp -User $vcAdmin

-Password $v ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~

    + CategoryInfo          : NotSpecified: (:) [Connect-HVServer], Exception

    + FullyQualifiedErrorId : System.Exception,VMware.VimAutomation.HorizonVie

   w.Commands.Cmdlets.ConnectHVServer

 

Any ideas?

 

Thank you very much.


PowerCLI 10.1.1 Released

Using PowerCLI to remove NSX Network Introspection driver from Windows Server 2008/2012/2016 VMWare Tools

$
0
0

I've been tasked to remove the NSX Network Introspection driver from Windows Server 2008/2012/2016 VMWare Tools.

Need to complete this task on about 400 Virtual Machines.

Was told this awesome community might have the building blocks for a PowerCLI script I could use the help me fix our environment.

Need a PowerCLI script to get the "ESXi host name", "Host Hardware Vendor Name", "Host hardware model", "IP address", "Product full name"

$
0
0

Need a PowerCLI script to get the "ESXi host name", "Host Hardware Vendor Name", "Host hardware model", "IP address", "Product full name"

We have about 15 vCenters which I want to grab all the vCenter hosts information with one time. Thanks in advance.

How to budget "groups of customers" with CPU/disk utilization?

$
0
0

SInce I could not find any documentation online, I opened ticket  17611994710 asking for documentation about this topic: We need to charge user groups depending on per-machine CPU-utilization and disk-utilization. So we need to read out this values per week (eg the VMs of your group used 12% of total CPU of the ESX cluster and used 2TB of disk space on LUN0 and 1TB on Lun1). How can we do that and get the data, so we can store it in a (SQL)

database?

 

We can obviously not use the graphs in the GUI (as suggested by the support as first answer), we need an script reading out parameters and storing them in a csv.

I got the answer to post in this group "Request you to choose the option "start a Discussion" and post you to requirement and our blog support team will update you."

 

I honestly find it curious that VMWare support can't provide me with a whitepaper or documentation (I did not ask for a script), but since they can't help, I would like to ask you if you already have a script I could use. I am ok with powershell, but never used powercli before. Thank you

get-stat timestamp difference

$
0
0

I dont know why there is difference in timestamp shown in UI and timestamp in get-stat of a ESXi server.

 

In the attached figure, you can see the current time is today's date: 2018/06/19

 

but when i get get-stat in powercli window.

i get

 

MetricId                Timestamp                          Value Unit

--------                ---------                          ----- ----

mem.usage.average       6/20/2018 9:09:20 AM                   0 %

mem.usage.average       6/20/2018 9:09:00 AM                   0 %

mem.usage.average       6/20/2018 9:08:40 AM                0.99 %

mem.usage.average       6/20/2018 9:08:20 AM                0.99 %

 

the timestamp shown is tomorrow's...

 

Is there anything which i have to change.

Get-VM Error after PowerCLI Upgrade

$
0
0

Hi,

 

I am unable to use get-vm command after the PowerCLI upgrade from 6.5.3 to 10.1.1

 

Below is the latest PowerCLI version details

 

Name                            Version
----                            -------
VMware.DeployAutomation         6.7.0.8250345
VMware.ImageBuilder             6.7.0.8250345
VMware.PowerCLI                 10.1.1.8827524
VMware.Vim                      6.7.0.8343295
VMware.VimAutomation.Cis.Core   10.1.0.8377811
VMware.VimAutomation.Cloud      10.0.0.7893901
VMware.VimAutomation.Common     10.1.0.8342134
VMware.VimAutomation.Core       10.1.0.8344055
VMware.VimAutomation.HA         6.5.4.7567193
VMware.VimAutomation.HorizonView7.5.0.8827468
VMware.VimAutomation.License    10.0.0.7893904
VMware.VimAutomation.Nsxt       10.1.0.8346947
VMware.VimAutomation.PCloud     10.0.0.7893924
VMware.VimAutomation.Sdk        10.1.0.8342078
VMware.VimAutomation.Srm        10.0.0.7893900
VMware.VimAutomation.Storage    10.1.0.8313015

VMware.VimAutomation.StorageUtility 1.2.0.0

VMware.VimAutomation.Vds        10.1.0.8344219
VMware.VimAutomation.Vmc        10.0.0.7893902
VMware.VimAutomation.vROps      10.0.0.7893921
VMware.VumAutomation           

6.5.1.7862888

 

When I execute get-vm I am getting the below error

 

PS E:\myreports> get-vm

get-vm : 6/19/2018 2:49:27 AM   Get-VM          Value cannot be null.

Parameter name: array

At line:1 char:1

+ get-vm

+ ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

 

 

 

 

similarly, If I give the VM name, it works

 

PS E:\myreports> get-vm VCENTER55

 

Name                 PowerState Num CPUs MemoryGB

----                 ---------- -------- --------

VCENTER55       PoweredOn  28       50.000

 

 

All my scripts are also failing

 

#Actual Script

Get-VM | Select @{N='VM Name';E={$_.Name}},

@{N="IP Address";E={@($_.guest.IPAddress[0])}},

@{N="VM_ID";E={@($_.ExtensionData.moref.value)}},

@{N="VM PowerState";E={@($_.PowerState)}},

@{N="Operating System"; E={@($_.guest.OSFullName)}},

@{N="CPU Count";E={@($_.NumCPU)}},

@{N="MemoryInGB";E={[math]::round($_.MemoryGB)}},

 

 

PS E:\myreports> .\4_POC_VM_Reporting.ps1

 

Name                           Port  User

----                           ----  ----

10.16.15.26                  443   admin

Get-VM : 6/19/2018 2:36:10 AM   Get-VM          Value cannot be null.

Parameter name: array

At E:\myreports\4_POC_VM_Reporting.ps1:8 char:1

+ Get-VM | Select @{N='VM Name';E={$_.Name}},

+ ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Exception calling "EnableAlarmActions" with "2" argument(s):

$
0
0

Hi,

 

I am trying to write a script that gives me the option to enable/disable alarm actions on all my ESXi hosts attached to a particular virtual center. 

 

I've got the code mostly working but I'm getting this error when I execute the code"

 

Exception calling "EnableAlarmActions" with "2" argument(s): "

Required parameter entity is missing

while parsing call information for method EnableAlarmActions

at line 1, column 171

while parsing SOAP body

at line 1, column 64

while parsing SOAP envelope

at line 1, column 0

while parsing HTTP request for method setAlarmActionsEnabled

on object of type vim.alarm.AlarmManager

at line 1, column 0"

At \\fs-55-ah\vmgr$\home05\dscotti\Documents\Scripts\WIP\set esxi host alarm state.ps1:37 char:13

+             $alarmmgr.EnableAlarmActions($esx.ExtensionData.MoRef,$tr ...

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

 

My script is attached. Any thoughts on what I've got wrong would be much appreciated.

 

Thanks

Dan


new-snapshot command hangs in invoke-command scriptblock

$
0
0

I'm trying to create a new snapshot in a powershell script that is running on system(s) that don't have PowerCLI installed. My thought is to use a PSSession to connect to a server that does have PowerCLI installed and run the New-SnapShot command in an Invoke-Command scriptblock. (Note: this process works for running SQL, SCOM and other modules on remote servers)

The problem I'm having is that the New-Snapshot command successfully creates the new snapshot, but then the PowerShell connection/session just hangs and never processes the next script line.

The script section looks like:

 

Param (

[string]$VCenterName,

[string]$VMName,

[string]$PowerCLIServer

)

 

$VCsession = New-PSSession -ComputerName "$PowerCLIServer";

$VCblock = {Import-Module VMware.VimAutomation.Core -DisableNameChecking;

    Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false;

    Connect-VIServer -Server $using:VCenterName -Protocol https;

    New-Snapshot -VM $using:VMName -Name Test -Confirm:$false;

    Return 1;

    };

Invoke-Command -Session $VCsession -ScriptBlock $VCblock;

 

When I run the script, the snapshot is created, but the '1' is never returned and the PowerShell session just hangs (never returns to the prompt).

How to format get-stat output on multiple metrics

$
0
0

Hello!

I'm trying to format the output from get-stat with multiple metrics into a format I can graph easily in Excel.  What I get from the command is in the format:

MetricId                Timestamp                          Value Unit    

--------                ---------                          ----- ----     --------

cpu.usage.average       6/19/2018 5:25:00 PM                4.77 %               

cpu.usage.average       6/19/2018 5:20:00 PM                4.66 %               

cpu.usage.average       6/19/2018 5:15:00 PM                4.76 %               

cpu.usage.average       6/19/2018 5:10:00 PM                4.34 %               

cpu.usage.average       6/19/2018 5:05:00 PM                 4.3 %               

cpu.usagemhz.average    6/19/2018 5:25:00 PM                2633 MHz             

cpu.usagemhz.average    6/19/2018 5:20:00 PM                2569 MHz             

cpu.usagemhz.average    6/19/2018 5:15:00 PM                2626 MHz             

cpu.usagemhz.average    6/19/2018 5:10:00 PM                2394 MHz             

cpu.usagemhz.average    6/19/2018 5:05:00 PM                2372 MHz  

 

and what I want is something like:

 

Timestampcpu.usage.averagecpu.usagemhz.average
5:25:004.772633
5:20:004.662569
5:15:004.762626
5:10:004.342394
5:05:004.32372

Can someone point me towards the cmdlets that would accomplish this?

 

Thank you!

New-Org fails in new vCD 9.1 environment

$
0
0

Built out a nested vCD 9.1 environment on vSphere 6.5 with NSX 6.4.0

Manually created my first organization and getting ready to create a powershell script to build the second one, but I get an error when using New-Org.  I am able to connect to the cell with Connect-CiServer without error and I can run Get-Org successfully.

 

 

New-Org -Name 'MyOrg1' -FullName 'My Organization 1'

 

New-Org : 6/20/2018 9:37:45 AM New-Org The specified Href 'https://Cell01.lab.local/api/Internal errror: ComposeOperationHref() : serviceUrl is not prefix

of sourceHref' is not valid.

At line:1 char:1

+ New-Org -Name 'MyOrg1' -FullName 'My Organization 1'

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-Org], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Cloud.Commands.Cmdlets.NewOrg

 

 

 

I've tried two different vCD installs (following the same process) and two different client machines.  PowerCLI 10.0 and 10.1

Server is using a self-signed cert

 

Any ideas what it is hanging up on?

New-TagAssignment works in .ps1, but not in .psf...

$
0
0

I have a very simple function I've created that creates Tags (if they don't exist), then assigns them to a VM. I created and tested this code in a normal .ps1 file first before porting it over to the Form Project. As stated in the subject, this code works perfectly fine in a .ps1, but if I try to add the exact same code to my Form Project, or even a bare-minimum .psf (with a single button to 'GO'), the script execution hangs/freezes forever when trying to execute the New-TagAssignment statement.

 

PLEASE NOTE: to test the code, change the Connect-VIServer and $VMname lines to be applicable to your environment.

 

I'm attaching 2 files to demonstrate what I'm talking about.  The code to do the Tag query and assignment are the same between the two files.  The only difference is one file is a regular .ps1 whereas the other file contains a GUI (.psf). 

  1. Doesn't_Work.psf - This is a very stripped down version of the GUI from my actual project. This file only contains the form and a single "GO" button to execute the code.  Even in this very basic version, the script hangs/freezes forever when trying to execute the New-TagAssignment cmdlet.
  2. Working.ps1 - This is strictly the code without a GUI.  This works perfectly...

 

After doing a tremendous amount of troubleshooting on my own, contacting Sapien support (the IDE I use for GUI powershell projects - Powershell Studio 2017 5.4.145.0), and massive Googling, I've come to the conclusion that there must be a bug in the cmdlet that is causing the hang/freeze.  There aren't any messages (error or otherwise) displayed; just straight up hangs/freezes forever.

 

I've seen many people with similar issues like I have (all concerning the "Tag" cmdlets), but I haven't seen any real/working resolution.

 

Here is the requested version info:

 

Name                       Value
PSVersion                  5.1.16299.98
PSEdition                  Desktop
PSCompatibleVersions       {1.0, 2.0, 3.0, 4.0...}
BuildVersion               10.0.16299.98
CLRVersion                 4.0.30319.42000
WSManStackVersion          3.0
PSRemotingProtocolVersion  2.3
SerializationVersion       1.1.0.1

 

ModuleTypeVersionName
Binary6.5.4.6983166VMware.VimAutomation.Cis.Core
Manifest6.5.4.6979861VMware.VimAutomation.Common
Binary6.5.2.6234650VMware.VimAutomation.Core
Manifest1.0.0.5334677VMware.VimAutomation.Sdk

 

vCenter ServerVersionBuild
**********.prime.cisco.com6.5.05973321

Need to gather information about VMs in specific datacenters in environment

$
0
0

I need to pull up a bunch of information for the VMs living in specific datacenters within a vCenter (5.1, ugh) environment right now. There are three datacenters with clusters within each (plus some hosts not in clusters, but still within the datacenter items). With about 4000 VMs total, I really need a solid way to pull the information from just one datacenter, or even from a single cluster/host within each set. The first target is the smallest, with only 18 hosts and 111 VMs listed in the summary of the DC.

 

I've found some scripts to pull the information (or a good chunk of it) but I really need it to be more specific (instead of shotgunning to everything).

 

Information I really need to pull:

VM name (obviously)

vNIC with portgroup connected to, plus how many of them (if more than one at least) along with the adapter type selected (e1000, etc.)

VMDK information including how many and which datastore it's on as well as what the type of datastore it is (VMFS, NAS, etc.).

Snapshot if present (I'd also prefer to have the total snapshot size if easy, but I can always gather that later).

Affinity rule(s) applied against the VM(s). If this can include which rule is applied, that would be great.

 

 

IMO, easy stuff to add would be the OS inside the VM, IP address, and power state. I'd also like to have the location information for the VM. Such as which datacenter, cluster and host. Or at least have that available and either enabled or disabled easily (add/remove # in front of the lines).

 

I've been asked to get all of this for the first target before end of the week. I'd like to have it sometime before EOD tomorrow. One of the scripts I found earlier today is still runnning.

 

Get-VM | Select-Object Name, Powerstate, NumCPU, MemoryGB, @{N="Noofdisk"; E={($_ | Get-HardDisk).count}}, HardDisks, @{N="Datastore"; E={($_ | Get-Datastore).Name}}, @{N="DiskState"; E={($_ | Get-HardDisk).storageformat}}, ProvisionedSpaceGB,  @{N="Snapshot"; E={($_ | Get-snapshot).count}}, VMHost,   @{N="OS"; E={$_.ExtensionData.summary.config.guestfullname}} | Export-Csv -NoTypeInformation -UseCulture -Path "C:\powercli_reports\Inventory4Result.csv$(Get-Date -f MM-dd-yyyy-H-mm-ss).csv"

 

The above script just finished and pulled up all the info listed in it (good sign). Can I simply add "NetworkAdapter," to the list to get the adapter type for each VM?? I'd still like to narrow down the target to just the DC/cluster I need to focus on (at each run time). Even if it means altering the script to be target specific. I'm also going to still need the rest of the info I listed above added to this. With each run taking over an hour (around 1-1/4 to 1-1/2 hours) it would be better. Especially when I can target a smaller group and get the results faster.

 

Hopefully someone will answer up soon (like LucD).

 

update: added the "Get-Datacenter ="<datacenter>" | " at the start to narrow it down. I can change it to a cluster later when I start hitting the one with over 3000 VMs in it (so it takes less time).

Still trying to figure out how to get the Network Adapter Type added to the list. I've tried added "@{N="NetworkAdapter"; E={($_ | Get-NetworkAdapter)}}" but it's not giving me the desired result...

 

Update2: changed the NIC line to "@{N="NetworkAdapter"; E={($_ | Get-NetworkAdapter).type}}" and that pulls the info needed for that section... Need to figure out how to add a NIC count line to this too (hope what I'm thinking will work, but will see).

 

Update3: I've managed to get almost everything needed. Except for a way to get the DRS affinity rule for any VMs they are applied against. Since this is going against a DC, is that just not possible? I'll consider pushing the script against a cluster tomorrow.

 

Message was edited by: golddiggie

Viewing all 14549 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>