Skip to content

Unable to run few PS1 scripts #1

@Anupthegeek

Description

@Anupthegeek

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

  •     $line = $content[$i]
    
  •     ~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

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

  •     $dateLine = $line.Split(",")[0]
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

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

  •     if ((Get-Date $dateLine) -gt (Get-Date $date)) {
    
  •                   ~~~~~~~~~
    
    • CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    • FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

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

  •     $line = $content[$i]
    
  •     ~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

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

  •     $dateLine = $line.Split(",")[0]
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

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

  •     if ((Get-Date $dateLine) -gt (Get-Date $date)) {
    
  •                   ~~~~~~~~~
    
    • CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    • FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

    2. vmUsage.ps1

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

  • $vms += Get-DesktopVM -Pool_id $pool.pool_id
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (vmware.view.pow...ts.GetDesktopVM:GetDesktopVM) [Get-DesktopVM], Ex
      ion
    • FullyQualifiedErrorId : No object,vmware.view.powershell.cmdlets.GetDesktopVM

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

  • $vms += Get-DesktopVM -Pool_id $pool.pool_id
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
    • FullyQualifiedErrorId : MethodNotFound

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

  • $vms += Get-DesktopVM -Pool_id $pool.pool_id
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
    • FullyQualifiedErrorId : MethodNotFound

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

  • $sessions += Get-RemoteSession -Pool_id $pool.pool_id -ErrorActio ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
    • FullyQualifiedErrorId : MethodNotFound

    3. unusedVMs.ps1

    & : File \vmmanager\E\Project\data\scripts\lastLogin.ps1 cannot be loaded. The file
    \vmmanager\E\Project\data\scripts\lastLogin.ps1 is not digitally signed. You cannot run this script on the current
    system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
    http://go.microsoft.com/fwlink/?LinkID=135170.
    At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\unusedVMs.ps1:11 char:12

  • $list = & $folder"scripts\lastLogin.ps1" $date
    
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess
      & : File \vmmanager\E\Project\data\scripts\lastLogin.ps1 cannot be loaded. The file
      \vmmanager\E\Project\data\scripts\lastLogin.ps1 is not digitally signed. You cannot run this script on the current
      system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
      http://go.microsoft.com/fwlink/?LinkID=135170.
      At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\unusedVMs.ps1:11 char:12
  • $list = & $folder"scripts\lastLogin.ps1" $date
    
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess
      & : File \vmmanager\E\Project\data\scripts\lastLogin.ps1 cannot be loaded. The file
      \vmmanager\E\Project\data\scripts\lastLogin.ps1 is not digitally signed. You cannot run this script on the current
      system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
      http://go.microsoft.com/fwlink/?LinkID=135170.
      At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\unusedVMs.ps1:11 char:12
  • $list = & $folder"scripts\lastLogin.ps1" $date
    
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess
      & : File \vmmanager\E\Project\data\scripts\lastLogin.ps1 cannot be loaded. The file
      \vmmanager\E\Project\data\scripts\lastLogin.ps1 is not digitally signed. You cannot run this script on the current
      system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
      http://go.microsoft.com/fwlink/?LinkID=135170.
      At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\unusedVMs.ps1:11 char:12
  • $list = & $folder"scripts\lastLogin.ps1" $date
    
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess
      & : File \vmmanager\E\Project\data\scripts\lastLogin.ps1 cannot be loaded. The file
      \vmmanager\E\Project\data\scripts\lastLogin.ps1 is not digitally signed. You cannot run this script on the current
      system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
      http://go.microsoft.com/fwlink/?LinkID=135170.
      At C:\Users\anupcp\Desktop\vmware-vdi-master\scripts\unusedVMs.ps1:11 char:12
  • $list = & $folder"scripts\lastLogin.ps1" $date
    
  •           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess

    4. lastLogin.ps1

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

  • ... teAndUser = Get-Content "$usageFileLocation$file" Select-String -NotM ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException
    • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand

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

  • ... teAndUser = Get-Content "$usageFileLocation$file" Select-String -NotM ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException
    • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand

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

  • ... teAndUser = Get-Content "$usageFileLocation$file" Select-String -NotM ...

  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException
    • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand

    Any help would be much appreicated.

    Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions