It worked when I changed the call to get-vApp as you suggested, Now my other command to get-vipermissions still throws the exception
The results of the "$stu.GetPrincipal()" is a string with my account information in it.
-=-=-=-=-=-=-==- Script:-=-=-=-=-=-=-=-=-
$vappName = "P,Michael-Mod6_Class"
$Principal = "outdomain\michael.p"
try {
$results = Get-VApp $vAppName | Get-VIPermission -Principal $Principal
# $results = get-vapp -location (get-folder -name michael.p)
} catch [System.ArgumentNullException] {
Write-Host "NULL Exception Raised. Close the session and run the script again." -ForegroundColor Yellow
Write-Host "StackTrace:`n$($_.ScriptStackTrace)" -ForegroundColor Red
Write-Host "Exception:`n$($_.Exception)" -ForegroundColor Red
Write-Host "Error Details:`n$($_.ErrorDetails)" -ForegroundColor Red
} catch {
Write-Host "An Error occurred trying to look at Permissions - May have to close Session and re-run script"
Write-Host "$_" -ForegroundColor Red
Write-Host "StackTrace:`n$($_.ScriptStackTrace)" -ForegroundColor Red
Write-Host "Exception:`n$($_.Exception)" -ForegroundColor Red
Write-Host "Error Details:`n$($_.ErrorDetails)" -ForegroundColor Red
}
Write-host "Results of TRY Command: "
$results | ft -AutoSize
-=-=-=-=-=-=-=-=-=-= Output -=-=-=-=-=-=-=-=-=
NULL Exception Raised. Close the session and run the script again.
StackTrace:
at <ScriptBlock>, <No file>: line 4
Exception:
VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.VimException: 10/8/2020 9:33:23 AM Get-VIPermission Value cannot be null.
Parameter name: collection ---> System.ArgumentNullException: Value cannot be null.
Parameter name: collection
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at VMware.VimAutomation.WorkloadManagement.Impl.V1.WMObnProvider.GetObn(IList`1 connectionIdList, IList`1 objectNameList, IList`1 objectInterfaceTypeList, IList`1 contextList, String contextRelationName)
at VMware.VimAutomation.WorkloadManagement.Impl.V1.WMObnProvider.GetObn(IList`1 connectionIdList, IList`1 objectNameList, IList`1 objectInterfaceTypeList, IList`1 contextList)
at VMware.VimAutomation.Sdk.Impl.V1.CoreServiceImpl.GetObn(IList`1 connectionIdList, IList`1 objectNameList, IList`1 objectInterfaceTypeList, IList`1 contextList, String contextRelationName)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ObnSelector.GetObjectsByNameCore(PropertyInfo parameter, String objectName)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ObnSelector.SelectObjectByNameCore(PropertyInfo parameter, String objectName)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ObnSelector.SelectObjectByName(PropertyInfo parameter)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ObnSelector.SelectObjectsByName()
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.SelectObjectsByName()
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.ProcessRecordErrorHandled()
at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.ProcessRecordErrorHandled()
--- End of inner exception stack trace ---
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
Error Details:
Results of TRY Command: