There's an undocumented bug in Azure Automation: it does NOT support the Process { } block, i.e. the block that you would use when creating scripts / modules where you need to support piping in your commands.
I discovered this after much trial and error trying to run a runbook and having it silently and mysteriously fail with no output whatsoever, no matter what verbosity and progress settings I enabled.
Showing posts with label block. Show all posts
Showing posts with label block. Show all posts
Sunday, August 13, 2017
Thursday, September 01, 2016
Unblocking zip files, the permanent solution
My team recently migrated their code to Visual Studio Online (aka VSO aka VSTS), which means that any time we do our builds, we now have to download our build output through the browser as a zip file rather than copying from a file share as we formerly did when our code was built on-premise. As a consequence of this, we now stumble across a feature of Windows: automatic file blocking.
Any time we download a zip from the internet, any scripts extracted from it are automatically blocked by Windows using metadata attached to the file in the NTFS file system. This means we have to manually unblock our scripts every time we download a build and want to deploy it (But Alex, why aren't you deploying your systems automatically through a deployment manager ? Our company isn't there yet, but we're getting there). That said, there's a way to disable this feature, detailed here:
http://winaero.com/blog/disable-downloaded-files-from-being-blocked-in-windows-10/
The short of it is that there exists a group policy for disabling tracking of zone information for files downloaded from the Internet.
Start -> Run -> gpedit.msc -> Local Computer Policy -> User Configuration -> Administrative Templates -> Windows Components -> Attachment Manager -> "Do not preserve zone information in file attachments" : Enabled.
Done.
Any time we download a zip from the internet, any scripts extracted from it are automatically blocked by Windows using metadata attached to the file in the NTFS file system. This means we have to manually unblock our scripts every time we download a build and want to deploy it (But Alex, why aren't you deploying your systems automatically through a deployment manager ? Our company isn't there yet, but we're getting there). That said, there's a way to disable this feature, detailed here:
http://winaero.com/blog/disable-downloaded-files-from-being-blocked-in-windows-10/
The short of it is that there exists a group policy for disabling tracking of zone information for files downloaded from the Internet.
Start -> Run -> gpedit.msc -> Local Computer Policy -> User Configuration -> Administrative Templates -> Windows Components -> Attachment Manager -> "Do not preserve zone information in file attachments" : Enabled.
Done.
Labels:
block,
blocked,
file,
gpedit.msc,
group policy,
information,
powershell,
ps1,
scripts,
unblock,
windows,
zip,
zone
Tuesday, August 23, 2016
Getting verbose output from an Invoke-Command -ScriptBlock in PowerShell
It's often very useful to invoke commands on other machines, e.g. in deployment scripts. It can be even more useful to have logging of what actually gets executed on those other machines, e.g.
$myJob = Invoke-Command -AsJob -ScriptBlock {
Param()
Do-Thing -Verbose
}
However, in this instance, you wouldn't get the output of the Do-Thing command because it's writing to the Verbose stream of a script block being executed on a separate machine. Now, it's not that PowerShell can't collect the output of that Verbose stream for you, it can. You just need to instruct it how. The difference:
$myJob = Invoke-Command -AsJob -Verbose -ScriptBlock {
[CmdletBinding()]
Param()
Do-Thing -Verbose
}
$myJob = Invoke-Command -AsJob -ScriptBlock {
Param()
Do-Thing -Verbose
}
However, in this instance, you wouldn't get the output of the Do-Thing command because it's writing to the Verbose stream of a script block being executed on a separate machine. Now, it's not that PowerShell can't collect the output of that Verbose stream for you, it can. You just need to instruct it how. The difference:
$myJob = Invoke-Command -AsJob -Verbose -ScriptBlock {
[CmdletBinding()]
Param()
Do-Thing -Verbose
}
Now you'll be able to collect the Verbose output of your script block. The difference is that you need to pass the Verbose flag to the script block, and make it a cmdlet by adding the [CmdletBinding()] attribute to your block.
Subscribe to:
Posts (Atom)