I am trying to resolve the Access denied error. The user that is attempting to run the script remotely is a member of the Remote Desktop Users group on the remote machine. The user is NOT a member of the local administrators group on the remote machine. I would prefer not to make them an administrator if there is another option.
Does anyone know how this can be done?
Thanks,
Matthew
When I attempt to run a powershell script that create remote apps on another computer I get the following error:
[USTSDEV3] Connecting to remote server USTSDEV3 failed with the following
error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (USTSDEV3:String) [], PSRemotingTrans
portException
+ FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
Batch file command that attempts to launch the powershell script on a remote computer:
Powershell -Command "Invoke-Command -ComputerName %TERMINAL_SERVER% -FilePath .\CreateRemoteApps.ps1"
Contents of CreateRemoteApps.ps1
<#
.SYNOPSIS
Creates the Remote Apps for Thruput on the specified server.
.DESCRIPTION
The remote apps that are found in Start -> All Programs -> Administrative Tools -> Remote Desktop Services -> RemoteApp Manager
are created by this script.
#>
Function CreateRemoteApp
{
Param
(
[string] $ApplicationName,
[string] $ApplicationPath,
[int] $ShowInWebAccess,
[int] $CommandLineSetting,
[string] $RequiredCommandLine
)
# Creates the full RDS: path to the application...
$RdsPath = [System.IO.Path]::Combine($RdsRoot, $ApplicationName)
"--------------------------------------------------------------------------------"
"Application Name: $ApplicationName`n"
"Creating the remote application`n"
If($RequiredCommandLine -ne "")
{
New-Item -Path $RdsRoot `
-Name $ApplicationName `
-ApplicationPath $ApplicationPath `
-ApplicationName $ApplicationName `
-ShowInWebAccess $ShowInWebAccess `
-CommandLineSetting $CommandLineSetting `
-RequiredCommandLine $RequiredCommandLine
}
else
{
# The RequiredCommandLine argument must be left out if it's empty...
New-Item -Path $RdsRoot `
-Name $ApplicationName `
-ApplicationPath $ApplicationPath `
-ApplicationName $ApplicationName `
-ShowInWebAccess $ShowInWebAccess `
-CommandLineSetting $CommandLineSetting
}
}
# Get the current computer name. This is needed in some of the RDS command line argument strings.
$ServerName = [System.Net.Dns]::GetHostName()
# All the Remote Apps exist in this RDS folder...
$RdsRoot = "RDS:\RemoteApp\RemoteAppPrograms"
"`nCreating Remote Applications for Thruput on: $ServerName`n"
# Enable the RDS provider...
Import-Module RemoteDesktopServices
# Get into the remote applications folder...
Set-Location $RdsRoot
# Delete all the current applications first...
Get-ChildItem | Remove-Item -Recurse
CreateRemoteApp "BR CopySchemaWin" "C:\Program Files (x86)\CopySchemaWin\CopySchemaWin.exe" 1 2 "21 verify"
CreateRemoteApp "BR Explorer" "C:\Windows\explorer.exe" 1 2 "C:\plants\brazil\"
CreateRemoteApp "BR Prod Batch DDQ" "C:\Windows\System32\cmd.exe" 1 2 "/c runas /user:$ServerName\administrator /savecred `"c:\mapicsscm61\resonance -nTP21Prod -ddq`""
CreateRemoteApp "BR Prod DButil" "C:\Windows\System32\cmd.exe" 1 2 "/c runas /user:$ServerName\administrator /savecred `"c:\mapicsscm61\dbutil -nTP21Prod`""
...