Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, May 12, 2011 3:29 PM
I have been tasked to create an XP Virtual Desktop Pool and was told I needed to run the script below.
However, when I do I get the following . . . I don't know SQUAT about poewershell put as I said, have been given a task that requires it.
ANY help would be GREATLY apprciated.
ERROR:
Missing function body in function declaration.
At line:1 char:16
- function Grant <<<< RDPPermission <[String]pandorasbox)
+ CatagoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorID : MissingFunctionBody
SCRIPT:
function Grant RDPPermissions ([String]$RDVHost)
{
$tsAccounts = @(Get-WMIObject -Namespace "root\cimv2" -Query "SELECT * FROM Win32_TSAccount WHERE (TerminalName = 'RDP-TCP' OR TerminalName = 'Console') AND AccountName = '$(pandorasbox.replace("\, "\"))')')")
if ($tsAccounts -eq $NULL -or $tsaccounts.count -eq 0)
{
Write-Host " pandorasbox is being added as a member of RDP-TCP permissions list"
$permissionSettings = @(Get-WmiObject -Namespace $nameSpace -Query "SELECT * FROM Win32_TSPermissionsSetting WHERE TerminalName = 'RDP-TCP'")
foreach($setting in $permissionSettings)
{
$setting.addaccount("pandorasbox", 1) | Out-Null
}
}
$tsAccounts = @(Get-WMIObject -Namespace $nameSpace -Query "SELECT * FROM Win32_TSAccount WHERE (TerminalName = 'RDP-TCP' OR TerminalName = 'Console') AND AccountName = '$(pandorasbox.replace("\, "\"))')')")
foreach($account in $tsAccounts)
{
if (($account.PermissionsAllowed -band 517) -ne 517)
{
Write-Host " Granting permissions : pandorasbox"
$account.ModifyPermissions(0,1) | Out-Null
$account.ModifyPermissions(2,1) | Out-Null
$account.ModifyPermissions(9,1) | Out-Null
}
}
}
dfkon
All replies (5)
Friday, May 13, 2011 2:59 PM âś…Answered
thanks much Alan, GREAT info. the second link: Appendix A: Configuring the Virtual Machine Manually is where I started, but doesn't work for XP machines - only windows 7 . . . guess no one wants to pool XP machines.
actually, got your 1st script to run . . . after Michael's help, I found on another forum that I needed to ad a $ in front of pandorasbox on the first line - then worked like a dream!
Thanks to both of you for the help!!
dfkon
Thursday, May 12, 2011 3:34 PM
note: the 1st line of the script should read: function Grant RDPPermissions ([String]pandorasbox)
NOT function Grant RDPPermissions ([String]$RDVHost)
and error should read:
Missing function body in function declaration.
At C:\VDP.ps1:1 char:16
- function Grant <<<< RDPPermissions ([String]pandorasbox)
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingFunctionBody
NOT:
Missing function body in function declaration.
At C:\VDP.ps1:1 char:16
- function Grant <<<< RDPPermissions ([String]pandorasbox)
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingFunctionBody
Thursday, May 12, 2011 8:50 PM
I'm a noob too but it seems that the space after Grant is causing problems. I don't think that function names can have spaces.
Thursday, May 12, 2011 9:13 PM
Thanks Michael, that got me a LITTLE farther . . .
Parameter declarations are a comma-separated list of variable names with optional initializer expressions.
At C:\VDP.ps1:1 char:40
- function GrantRDPPermissions ([String] <<<< pandorasbox)
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidFunctionParameter
dfkon
Friday, May 13, 2011 7:03 AM
Hi,
Please check whether you miss any character from the following article: (I test the function Grant-RDPPermissions, its fine)
Configure Guest OS for Microsoft VDI (Windows PowerShell Script)
http://gallery.technet.microsoft.com/ScriptCenter/bd2e02d0-efe7-4f89-84e5-7ad70f9a7bf0/
Meanwhile, you can configure he Virtual Machine Manually beads on the article as followed:
Appendix A: Configuring the Virtual Machine Manually
http://technet.microsoft.com/en-us/library/ff603843(WS.10).aspx
Thanks.