我无法UserAssignment
使用 .net 访问容器。我能够进入应用程序容器,但没有进一步。任何想法将不胜感激。我正在使用的代码是:
Private Function runScript2(userName As String, applicationName As String) As String
Dim rs As Runspace = RunspaceFactory.CreateRunspace
rs.Open()
Dim ps As PowerShell = PowerShell.Create
ps.Runspace = rs
Dim sb2 As New StringBuilder
sb2.AppendLine("Import-Module -Name C:\RemoteDesktopServices\RemoteDesktopServices.psd1")
sb2.AppendLine("Get-ChildItem -Path RDS:\") 'this works
sb2.AppendLine("Get-ChildItem -Path RDS:\RemoteApp\RemoteAppPrograms\WordPad\") 'this works
sb2.AppendLine("Get-ChildItem -Path RDS:\RemoteApp\RemoteAppPrograms\WordPad\UserAssignment") 'this does not work, no error
sb2.AppendLine("Get-ChildItem -Path C:\MyScripts")
ps.AddScript(sb2.ToString)
Dim output As Collection(Of PSObject) = ps.Invoke
Dim sb As New StringBuilder
For Each obj As PSObject In output
If TypeOf (obj.BaseObject) Is DirectoryInfo Then
Dim fle As DirectoryInfo = CType(obj.BaseObject, DirectoryInfo)
sb.AppendLine(fle.FullName)
ElseIf TypeOf (obj.BaseObject) Is FileInfo Then
Dim fle As FileInfo = CType(obj.BaseObject, FileInfo)
sb.AppendLine(fle.FullName)
Else
sb.AppendLine(obj.BaseObject.ToString)
End If
Next
Return sb.ToString
End Function