Below error
PowerCLI C:\users\cz3m7g\desktop\scripts\VM_created _date> $eventNr = 9999
PowerCLI C:\users\cz3m7g\desktop\scripts\VM_created _date> & '.\vm created date.
ps1'
Select-Object : A positional parameter cannot be found that accepts argument '$
null'.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:5 char:
24
+ $row = "" | Select <<<< Date, Msg, User, Cluster, Host $row.Date =
$_.createdTime
+ CategoryInfo : InvalidArgument: (:) [Select-Object], ParameterB
indingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
.Commands.SelectObjectCommand
Property 'Msg' cannot be found on this object; make sure it exists and is setta
ble.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:6 char:
11
+ $row. <<<< Msg = $_.fullFormattedMessage
+ CategoryInfo : InvalidOperation: (Msg:String) [], RuntimeExcept
ion
+ FullyQualifiedErrorId : PropertyNotFound
Property 'User' cannot be found on this object; make sure it exists and is sett
able.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:7 char:
11
+ $row. <<<< User = $_.userName
+ CategoryInfo : InvalidOperation: (User:String) [], RuntimeExcep
tion
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Cluster' cannot be found on this object; make sure it exists and is s
ettable.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:8 char:
11
+ $row. <<<< Cluster = (Get-View $_.computeResource.computeResource).Name
+ CategoryInfo : InvalidOperation: (Cluster:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : PropertyNotFound
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:9 char:
27
+ $row.Host = (Get-View <<<< $_.Host.Hostt).Name
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Select-Object : A positional parameter cannot be found that accepts argument '$
null'.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:5 char:
24
+ $row = "" | Select <<<< Date, Msg, User, Cluster, Host $row.Date =
$_.createdTime
+ CategoryInfo : InvalidArgument: (:) [Select-Object], ParameterB
indingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
.Commands.SelectObjectCommand
Property 'Msg' cannot be found on this object; make sure it exists and is setta
ble.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:6 char:
11
+ $row. <<<< Msg = $_.fullFormattedMessage
+ CategoryInfo : InvalidOperation: (Msg:String) [], RuntimeExcept
ion
+ FullyQualifiedErrorId : PropertyNotFound
Property 'User' cannot be found on this object; make sure it exists and is sett
able.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:7 char:
11
+ $row. <<<< User = $_.userName
+ CategoryInfo : InvalidOperation: (User:String) [], RuntimeExcep
tion
+ FullyQualifiedErrorId : PropertyNotFound
Property 'Cluster' cannot be found on this object; make sure it exists and is s
ettable.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:8 char:
11
+ $row. <<<< Cluster = (Get-View $_.computeResource.computeResource).Name
+ CategoryInfo : InvalidOperation: (Cluster:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : PropertyNotFound
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At C:\users\cz3m7g\desktop\scripts\VM_created _date\vm created date.ps1:9 char:
27
+ $row.Host = (Get-View <<<< $_.Host.Hostt).Name
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
PowerCLI C:\users\cz3m7g\desktop\scripts\VM_created _date>
=============
script
# How many days in the past to start from $start = (Get-Date).AddDays(-10)
# The more days back, the higher this number should be. $eventNr = 9999 $report = @()
Get-VIEvent -Start $start -MaxSamples $eventNr | Where-Object {$_.GetType().Name -eq "VmCreatedEvent"} | % {
$row = "" | Select Date, Msg, User, Cluster, Host $row.Date = $_.createdTime
$row.Msg = $_.fullFormattedMessage
$row.User = $_.userName
$row.Cluster = (Get-View $_.computeResource.computeResource).Name
$row.Host = (Get-View $_.Host.Hostt).Name
$report += $row
}
$report