Try like this
$esxNames='esx1','esx2'
$user='root'
$pswd='secret_password!'
$now=Get-Date
foreach($esxNamein$esxNames){
$srv=Connect-VIServer-Server$esxName-User$user-Password$pswd
Get-VM-Server$srv|Get-Snapshot|
Where{(New-TimeSpan-Start$_.Created -End$now).TotalDays -ge7} |
Select @{N='VMName';E={$_.VM.Name}},
@{N='VMState';E={$_.vm.PowerState}},
@{N='VMHost IP Details';E={(Get-VMHostNetworkAdapter-VMKernel-VMHost$_.vm.VMHost).IP -join'|'}},
@{N='ProvisionedSpaceGB';E={[math]::Round($_.VM.ProvisionedSpaceGB,2)}},
@{N='UsedSpaceGB';E={[math]::Round($_.VM.UsedSpaceGB,2)}},
@{N='Datastore';E={($_.vm |Get-Datastore).Name -join'|'}},
@{N='Datastore Capacity';E={($_.vm |Get-Datastore).CapacityGB -join'|'}},
@{N='SnapshotName';E={$_.Name}},
@{N='SnapshotDate';E={$_.Created}},
@{N='SnapshotSizeGB';E={[math]::Round($_.SizeGB,2)}},
@{N='SnapshotCreator';E={
Get-VIEvent-Start$_.Created.AddMinutes(-1) -Finish$_.Created.AddMinutes(1) |
where{$_-is[VMware.Vim.TaskEvent]-and$_.Info.DescriptionId -eq'VirtualMachine.createSnapshot'} |
select-Last1-ExpandPropertyUserName}}
Disconnect-VIServer-Server$esxName-Confirm:$false
}