Hello all,

I recently posted a question about a Windows Feature Remote Desktop 
Services (formaly known as Terminal Services)

https://groups.google.com/forum/?fromgroups=#!searchin/puppet-users/remote$20desktop/puppet-users/q71sP3TZZXQ/ymuAMqX5OTsJ

the basic problem is

fresh installed version of windows 2008 r2
use puppet to install remote desktop services
requires reboot
when server comes back online, its in protected mode (so no one can install 
applications without issuing the following command "change user /install)
puppet agent fails to run 

what I discovered was, once remote desktop services was installed
if you run
change user /install
then run puppet agent it runs fine
then exit out of install mode
change user /execute

everything works how it should.

so i've tried to come up with something, but its not working can anyone 
help or advice

1.) create custom fact, to see if TerminalServer service is running equal 
true


Facter.add("remote_desktop") do
  setcode do
    
Facter::Util::Resolution.exec('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
 
-ExecutionPolicy remotesigned -File 
C:\installs\Scripts\remote_desktop_installed_fact.ps1')
  end
end


1.1) Powershell Script remote_desktop_installed_fact.ps1

Function remote-desktop()
{
$Service=Get-Service TermService -ComputerName localhost
if ($Service.status -eq "Running")
{
    write-host "true"
}
else
    {
    Write-host "false"
    }
}
remote-desktop

Then i thought the following would work but it doesn't, can you please help


if $::remote_desktop == true {
exec  { 'change_user_install':
command   => 'C:\Windows\System32\cmd.exe /c "change user /install"',
}->

exec { 'remote_desktop_services_install':
command   => 'C:/Windows\System32\WindowsPowerShell\v1.0\powershell.exe 
-executionpolicy remotesigned -file 
C:\Installs\Scripts\remote_desktop_services.ps1',
creates   => 
'c:/Installs/Puppet_Confirmation/Remote_Desktop_Services_Installed.txt',
require   => Class [ 'roles::base::dot_net' ],
}->

exec  { 'change_user_execute':
command   => 'C:\Windows\System32\cmd.exe /c "change user /execute"',
require   => exec['remote_desktop_services_install']
}
}
else {
exec { 'remote_desktop_services_install_1':
command   => 'C:/Windows\System32\WindowsPowerShell\v1.0\powershell.exe 
-executionpolicy remotesigned -file 
C:\Installs\Scripts\remote_desktop_services.ps1',
creates   => 
'c:/Installs/Puppet_Confirmation/Remote_Desktop_Services_Installed.txt',
require   => Class [ 'roles::base::dot_net' ],
}
}}



Here is the powershellscript - remote_desktop_services.ps1


$strFileName = "c:\ProgramData\PuppetLabs\Puppet 
Enterprise\var\state\puppetlockd"

Import-Module Servermanager
Add-WindowsFeature -Name RDS-RD-Server -IncludeAllSubFeature
Add-Content 
"c:\Installs\Puppet_Confirmation\Remote_Desktop_Services_Installed.txt" 
"Windows has finished installing Remote Desktop Services"
start-sleep -s 60
IF (Test-Path $strFileName){
        Remove-Item $strFileName }

shutdown /r /t 60

Could it be becuase i've used
creates   => 
'c:/Installs/Puppet_Confirmation/Remote_Desktop_Services_Installed.txt',

on both scripts and one blocks out the other from running

hope this make sense

regards


James



-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to