example-scripts/schedule-import.ps1
# $script1 = [scriptblock]::Create("Write-Host -Object ""Hello World""") # Invoke-Command -ScriptBlock $script1 # $hw = @{ Object = "Hello World with Splatting!" } # $script2 = [scriptblock]::Create("Write-Host @hw") # Remove-Variable -Name "hw" # Invoke-Command -ScriptBlock $script2 $params = @{ SolutionName = "RecordLocked" CrmInstance = "CRMRECRUITTEST" Managed = "`$false" PublishCustomizations = "`$false" Emails = "dhines@regent.edu" } (Get-Date).ToFileTime() $script = [scriptblock]::Create("Import-RegentSolution -Verbose $(&{$args} @params)") # Invoke-Command -ScriptBlock $script $trigger = New-JobTrigger -Once -At (Get-date).AddSeconds(3) Register-ScheduledJob -Name "$($params.SolutionName)-$((Get-Date).ToFileTime())" -Trigger $trigger -ScriptBlock $script # Remove-Variable -Name "params" # $script3 = [scriptblock]::Create("Echo-Params -TestParam $(&{$args} @params)") # Invoke-Command -ScriptBlock $script3 # $AllEmailParams = # @{ # From = "Foo" # Subject = "Bar" # } # $ThisEmailParams = # @{ # To = "Foo" # } # $Scriptblock = [Scriptblock]::Create( # "Echo-Params $(&{$args} @AllEmailParams @ThisEmailParams)") # Remove-Variable -Name "AllEmailParams" # Remove-Variable -Name "ThisEmailParams" # Invoke-Command -ScriptBlock $Scriptblock |