Puppet Module to run a custom PowerShell script.
This Puppet Module will attempt to run a custom PowerShell script within a new PowerShell process in order to preserve the parent process privileges.
class webserverpostdeploymentscripts {
if $osfamily == 'windows' {
$wsrpsscriptfile = 'restart-website.ps1'
$powershellexe = 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'
$wsrpsscriptpath = "C:/Windows/Temp/${wsrpsscriptfile}"
file { 'restart-psscript':
path => $wsrpsscriptpath,
ensure => "file",
source => "puppet:///files/$wsrpsscriptfile"
} ->
exec { 'restart-website':
command => "start-process -verb runas $powershellexe -argumentlist '-file ${wsrpsscriptpath}'",
provider => "powershell"
}
}
}
Written by Jorge Medina
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Powershell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#