Windows PowerShell, first introduced with the release of Windows Vista and Windows Server 2008, is a distributed automation engine, command-line shell, and scripting language that is constructed on the Microsoft® .NET Framework. It is designed especially for automating Windows management.
Questions tagged [powershell-workflow]
94 questions
29
votes
2 answers
How to define named parameter as [ref] in PowerShell
I'm trying to use [ref] named parameters. However, I am getting an error:
workflow Test
{
Param([Parameter(Mandatory=$true)][String][ref]$someString)
write-verbose $someString -Verbose
$someString = "this is the new…

David Klempfner
- 8,700
- 20
- 73
- 153
13
votes
4 answers
Understanding scope of functions in powershell workflow
Copy and paste the following into a new Powershell ISE script and hit F5:
workflow workflow1{
"in workflow1"
func1
}
function func1 {
"in func1"
func2
}
function func2 {
"in func2"
}
workflow1
the error I get is:
The term…

jamiet
- 10,501
- 14
- 80
- 159
8
votes
3 answers
Calling a Function From Another Function in PowerShell
First time in PowerShell 5 and I'm having trouble calling a function that writes messages to a file from another function. The following is a simplified version of what I'm doing.
workflow test {
function logMessage {
param([string]…

Malcont3nt
- 430
- 1
- 4
- 11
7
votes
2 answers
Call a function from an InlineScript
How can I call a function in a workflow from a nested InlineScript?
The following throws an exception because the function is out of scope in the InlineScript:
Workflow test
{
function func1
{
Write-Verbose "test verbose" -verbose
…

David Klempfner
- 8,700
- 20
- 73
- 153
6
votes
3 answers
How to Increase number of cuncurrent powershell instance on VM?
I am trying to trigger a powershell workflow which should spin 10 threads in parallel. I am using PS version 4. Code -
Workflow CreateVMs
{
$i = 0
#somecodehere...
foreach -parallel -throttlelimit 10($i in 0..30)
{
…

Aatif Akhter
- 2,126
- 1
- 25
- 46
5
votes
1 answer
Unable to resume a workflow via task scheduler
In a powershell window I run the following workflow:
workflow foo { Suspend-Workflow; "hello world" | Out-File c:\users\weijgerss\desktop\foo.txt }
Then to resume the workflow, I have the following scheduled via task scheduler triggered to run at…

simonweijgers
- 220
- 1
- 3
- 9
4
votes
2 answers
How to hide console output from Select-AzureRmSubscription
Does anyone know how to hide output from command Select-AzureRmSubscription inside azure workbook which runs as powershell workflow
Thanks

Rafal
- 217
- 1
- 3
- 9
4
votes
2 answers
Does powershell's parallel foreach use at most 5 thread?
The throttlelimit parameter of foreach -parallel can control how many processes are used when executing the script. But I can't have more than 5 processes even if I set throttlelimit greater than 5.
The script is executed in multiple powershell…

Haoshu
- 832
- 7
- 19
4
votes
1 answer
Creating objects parallel in powershell workflow and adding it to an array
I need to create many objects in parallel inside a workflow and add all of the objects to an array. My code would be something like this
workflow sample {
$ans=@()
$arr=@(1,2,3)
foreach -parallel ($a in $arr){
$obj= New-Object…

saravanan
- 398
- 4
- 13
4
votes
1 answer
Invoke-WebRequest not working in Azure Automation
Invoke-WebRequest is not working in Azure.
I have tested the same code in Powershell ISE and it works.
Here is the error:
4/8/2015 9:24:14 AM, Error: Microsoft.PowerShell.Utility\Write-Error : aa00-csmo-t2 - Could not download…

David Klempfner
- 8,700
- 20
- 73
- 153
3
votes
0 answers
Powershell Foreach -Parallel not reaching throttle limit
I have a script using workflows and Foreach -Parallel -ThrottleLimit 15 which works fine if the code inside the loop is something simple like write-output or some basic math and a sleep statement, but when I swap in the actual logic (updating…

Jaboc83
- 302
- 1
- 2
- 8
3
votes
3 answers
Using a recursive function beside a workflow
I have a PowerShell script whose purpose is to get a list of files then do some work on each file.
The list of files is generated by a recursive function like this:
function Recurse($path)
{
.. create $folder
foreach ($i in $folder.files) {…

Artog
- 1,132
- 1
- 13
- 25
3
votes
0 answers
How do you format drive at startup after a restart in a workflow?
I am trying to reformat a hard drive at startup to 64K after deleting pagefile and a reboot, but the Format-Drive cmdlet does not run.
I have also tried changing the trigger to run at logon of user.
Any suggestions on what I am overlooking?
workflow…

Brian Doetsch
- 53
- 5
3
votes
1 answer
How to log to Powershell console from Workflow Job
I have a Powershell workflow. I need to log data to Console so that the progress of the workflow is clearly visible. Till now I used Log-Verbose to achieve this. When I execute this workflow with -Verbose switch, verbose logs are displayed on the…

bittusarkar
- 6,247
- 3
- 30
- 50
3
votes
2 answers
Determine if a .pfx file needs a password before calling Add-AzureCertificate
I am using the following code to install a .pfx file on an Azure Cloud Service:
Add-AzureCertificate -serviceName $CloudServiceName -certToDeploy $PfxFile.FullName -ErrorAction 'Stop' -Password $applicationCertsPassword
I think it's throwing an…

David Klempfner
- 8,700
- 20
- 73
- 153