Skip to content

Instantly share code, notes, and snippets.

@mkesper
Last active August 29, 2015 14:24
Show Gist options
  • Save mkesper/357595053ace2ca6acc2 to your computer and use it in GitHub Desktop.
Save mkesper/357595053ace2ca6acc2 to your computer and use it in GitHub Desktop.
Powershell Invoke-Expression Parameter Trouble
Set-StrictMode -Version "2.0"
function ProcessContent{
$FileName = Join-Path "C:\PATH\IN" ("{0}.JSON" -f $PlannedChanges.Anforderung.Changenummer)
$PlannedChanges|ConvertTo-Json -Compress|Out-File -Encoding utf8 $FileName
Invoke-Expression "C:\PATH\Skript\MoveHome.ps1 -changenummer $PlannedChanges.Anforderung.Changenummer"
}
Get-ChildItem "C:\PATH\IN" -Filter *.TXT | Where-Object{$_.FullName -ne $null} |`
ForEach-Object{
ProcessContent
}
param([string]$changenummer = "")
Set-StrictMode -Version "2.0"
Write-Output ("MoveHome - Processing: {0}" -f $Changenummer)
@mkesper
Copy link
Author

mkesper commented Jul 10, 2015

Seems everything is ok after putting script and parameters in quotes but I got caught by "throw" messing up different contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment