我無法使用.net訪問UserAssignment
容器。我能夠到達應用程序容器,但沒有更多。任何想法將不勝感激。我使用的代碼是:遠程桌面PowerShell腳本
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
您是否使用Windows Server 2008 R2? – 2012-04-18 06:19:09
是服務器正在運行2008 R2 – DaddioNTS 2012-04-18 12:45:51