Я не могу получить доступ к контейнеру UserAssignment
, используя .net. Я могу добраться до контейнера приложения, но не дальше. Любые идеи очень приветствуются. Код я использую:Удаленный рабочий стол PowerShell Scripting
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? –
Да, сервер работает 2008 R2 – DaddioNTS