SethosII / vmware-vdi

Scripts and other utilities to administer a VMware Horizon (formerly: View) environement
GNU Lesser General Public License v3.0
5 stars 2 forks source link

Unable to run few PS1 scripts #1

Open Anupthegeek opened 3 years ago

Anupthegeek commented 3 years ago

Hi,

I am unable to run below scripts, I get the exceptions as stated:

1. vmUsers.ps1

Cannot index into a null array. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:27 char:3

You cannot call a method on a null-valued expression. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:28 char:3

Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type "System.DateTime"." At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:30 char:17

Cannot index into a null array. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:27 char:3

You cannot call a method on a null-valued expression. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:28 char:3

Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type "System.DateTime"." At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsers.ps1:30 char:17

Get-DesktopVM : No output object matching the Pool_id parameter At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsage.ps1:13 char:10

Method invocation failed because [vmware.view.powershell.cmdlets.DesktopVM] does not contain a method named 'op_Addition'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsage.ps1:13 char:2

Method invocation failed because [vmware.view.powershell.cmdlets.DesktopVM] does not contain a method named 'op_Addition'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsage.ps1:13 char:2

Method invocation failed because [vmware.view.powershell.cmdlets.RemoteSession] does not contain a method named 'op_Addition'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\vmUsage.ps1:12 char:2

Get-Content : A positional parameter cannot be found that accepts argument 'Select-String'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\lastLogin.ps1:23 char:17

Get-Content : A positional parameter cannot be found that accepts argument 'Select-String'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\lastLogin.ps1:23 char:17

Get-Content : A positional parameter cannot be found that accepts argument 'Select-String'. At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\lastLogin.ps1:23 char:17

SethosII commented 3 years ago

@Anupthegeek:

  1. The script can't find data that needs to be generated in advance by vmUsage.ps1, therefore the variables are empty and you see these errors.
  2. I think you are missing the VMware Horizon Powershell modules because of the ObjectNotFound error or the expression on the right needs to be placed in parentheses.
  3. This seems to be running on a different computer. Your powershell execution policy on this one does not allow to run the script.
  4. The pipes are missing in the file, so something went wrong while copying the script or so. The line should look like this: https://github.com/SethosII/vmware-vdi/blob/master/scripts/lastLogin.ps1#L23.