93 questions
0
votes
1
answer
35
views
Format change not working if there is small change in input
I have a file with below content, i wanted to convert all the build jobs into a different format like in expected output.
parallel
(
{
build( "job2", parameter3: value3, parameter4: ...
0
votes
0
answers
577
views
Powershell Foreach -Parallel not running in parallel
I want to test for the existence of a file path on many computers, using SMB. Many of these computers will be offline, and it takes several seconds for the SMB request to time out, so I want to run ...
0
votes
1
answer
721
views
PowerShell script doesnt continue after reboot
I am pretty new to PowerShell scripting so I wanted to write a script that helps our apprentices in setting up new laptops for our customers.
This script should rename the computer, then restart it ...
-1
votes
1
answer
65
views
Script to rename and reboot a Computer throws out an file access error despite being run in an admin PowerShell
Running a workflow which renames and restarts the computer results in an error.
I had to put in screenshots because I somehow could post the code in here.
PowerShell code
Error code
0
votes
0
answers
45
views
Execute command with relative path inside Inline script
I've the following code to execute parallels command in powershell
workflow Test-Workflow {
$Sites = "Param1", "Param2", "Param3"
ForEach -Parallel ($...
0
votes
1
answer
1k
views
Powershell workflow with "foreach -parallel" and Invoke-AZVMRunCommand- how to get results out?
I have a bunch of VMs in Azure I want to run the same script against. Because of reasons, I can't use powershell 7, so I have to use powershell 5. Which means I can use "foreach -parallel", ...
0
votes
1
answer
505
views
Powershell Is it possible to start process -wait in parallel
I tried something like this and it starts one after the other
function start-parallel {
workflow work {
start-process $exe1 -wait
start-process $exe2 -wait
}
work
}
0
votes
1
answer
425
views
Using powershell jobs to track powershell winRM remoting NO winRM timeout
I have got a powershell script working, the job runs a list of servers, remotely connects to the servers and runs a simple script to get the hostname from the server. The issue is that it does get ...
0
votes
0
answers
696
views
Error with Powershell Workflow in Automation Account foreach -parallel
I have issues publishing a PowerShell workflow. Most of the script I am using is run in sequence, including the first for loop. But I would like to final for loop to execute in parallel. The code is ...
0
votes
0
answers
398
views
How to invoke a function defined in another Powershell script within a Workflow?
Usually, I use dot-sourcing to "import" my function defined in other script files.
But the Powershell Workflow does not allow dot-sourcing, and it can't recognize functions defined out of ...
0
votes
1
answer
326
views
Posh-SSH is giving an error when in WorkFlow
I wrote a script to export rows from a SQL DB, encrypt them using PGP, then transfer them using POSH-SSH v2.3.0. It all works fine, until I put it in a PowerShell WorkFlow to run multiple at a time.
...
0
votes
3
answers
350
views
Adding a new property to an array of objects. Parallel
I'd like to add a new property to an array of objects. Add-member doesn't work, please assist
$computers = Get-ADComputer -Filter {(name -like "SMZ-*-DB")} | select -First 30
workflow test-...
0
votes
1
answer
281
views
Azure Automation Runbook Workflow looses AzContext
I have written the following runbook workflow, but from time to time I see the error when it try's to start or stop a VM:
Start-AzVM : Your Azure credentials have not been set up or have expired, ...
0
votes
1
answer
4k
views
How can I print to the console inside a PowerShell parallel loop
I have a simple workflow for running some commands within a parallel foreach loop, but cannot figure out how to print to the console from within the loop.
$names = @('foo', 'bar', 'bat')
Workflow ...
0
votes
2
answers
1k
views
Pass multiple arguments/parameters to powershell workflow
I have a powershell workflow script as below:
workflow mytest{
param($param1,$param2,$param3)
//code
}
mytest $param1,$param2,$param3
Issue here is all the three params were received as ...
0
votes
1
answer
1k
views
How to make RunBook recognize DateTime type?
I am creating a Powershell workflow in Azure Automation.
When setting DateTime type Set-AutomationVariable with function,
Recognized as a string. Please let me know if you know how to solve it.
...
0
votes
1
answer
388
views
How to get values from workflow parallel code block?
I'm trying to run two Invoke-Sqlcmd in parallel and then wait all the results.
$server1 = '...'
$server2 = '...'
workflow work {
parallel {
$r1 = Invoke-Sqlcmd -ServerInstance $server1 'select ...
1
vote
1
answer
937
views
PowerShell workflow Invoke-Command not working (Write-Host)
Currently trying to use PowerShell workflow to process some remote server stuff that I am doing in parallel.
I am having no luck trying to get the Invoke-Command to log onto the server to actually ...
0
votes
1
answer
187
views
Include PowerShell Workflow Scripts in a Workflow
I have several Workflow scripts defined.
I want to write a master script to reference the dependent scripts.
I am expecting there is some kind of Import or Include statement to reference the dependent ...
1
vote
1
answer
314
views
PowerShell workflow doesn't work in Jenkins?
I have a script in PowerShell. It's running from Jenkins via a PowerShell step. Without Jenkins all works fine. But when I build it with Jenkins, I got nothing... no errors, just nothing. What's ...
0
votes
1
answer
2k
views
foreach -parallel in PowerShell
I have written a script to get the offline cluster resources using foreach syntax and it is working fine. But I need to get the cluster offline resources for 50 clusters and I have tried foreach -...
1
vote
2
answers
645
views
Logging issue for function call in powershell-workflow
The issue I'm facing is logging the output of a function being called inside the powershell workflow into a logfile.
Tried using Out-File but it is not supposed to be used for logging a specific ...
0
votes
1
answer
3k
views
Check if a reboot is needed and continue Powershell script after reboot?
This question was asked a few times before but I could not find a solution to my scenario in any of them.
Basically I need the script to continue after it reboots if needed. It will check a few ...
0
votes
0
answers
324
views
Array output from Powershell Workflow not formatting or exporting properly
So I wrote a script to go through and optimize some VHDX files and output the results. In an effort to reduce the script run time (dramatically), I taught myself Workflow. That was an adventure on it'...
1
vote
1
answer
386
views
How to pass args to the parallel foreach
I get list of endpoints as arguments to my script, I want to send http request to all of them, but I don't want to do it in sequence, but rather simultaneously. I found that there is something like ...
0
votes
0
answers
396
views
Disable UAC, restart and install programs
I tried to disable UAC, restart the machine and install the program. I found an article how can create workflow, but it not works for me. When I run it once, the computer restarts, UAC is still ...
0
votes
1
answer
692
views
Pass arguments to Invoke-Command
This is my script:
workflow Run-RemoteScript {
Param(
[Parameter(Mandatory,Position=0)][string[]]$Targets,
[Parameter(Mandatory,Position=1)][PSCredential]$Credentials,
[...
0
votes
0
answers
412
views
Update global variable from workflow
function function1(){
Param($a)
"YOU HAVE entered : $a"
$arr+=$a
$arr2.Add($a)
}
workflow wf{
Param($b)
Parallel{
sequence{
function1 $b
}
...
0
votes
1
answer
3k
views
Parallel T-SQL execution in PowerShell
Can anyone help with this problem? I am referring to a example from the internet for executing T-SQL statements in parallel.
https://www.mssqltips.com/sqlservertip/3539/complete-common-sql-server-...
0
votes
2
answers
2k
views
Issue while exporting output to CSV in PowerShell Parallel Workflow
I am using below script to get the details about port status of multiple remote servers.
Workflow Test-OpenPortWF
{
[CmdletBinding()]
param
(
[Parameter(Position=0)]
[...
1
vote
0
answers
263
views
Workflows return unpredictable results on long workflow calls in foreach parallels
When I call a workflow in another workflow's foreach -parallel, I get weird and inconsistent results. Here's some sample code:
workflow test-workflow1 {
Start-Sleep 2
"Stuff"
}
workflow test-...
2
votes
0
answers
944
views
Playing around with object in Powershell Workflow
I'm trying to learn how to use Workflow in Powershell and how to get around the restrictions applied to variables (And objects in my case). But I'm facing an issue when I'm trying to modify a workflow-...
0
votes
1
answer
549
views
How to iterate over Object properties of an input parameter
I have an Azure Automation Powershell Workflow:
workflow wf
{
param(
[parameter(Mandatory=$True)]
[object] $p
)
inlinescript
{
# ...
}
}
I am testing it using the Test pane and ...
0
votes
0
answers
464
views
Powershell Workflows
I wrote a PowerShell workflow that analyses the Excel data and triggers a mail based on the values in Excel.
I have developed a workflow which triggers mail but I'm having trouble in analysing the ...
1
vote
1
answer
2k
views
Return multiple values in PowerShell
Given the following Script, how can I return two variables to the main code?
I have tried the return command but show an error. Please find the code and error message below.
Code:
workflow Test-...
1
vote
1
answer
5k
views
Unable to connect to remote server when trying to call Invoke-RestMethod from Azure Runbook
I am encountering this error when trying to call Invoke-RestMethod from Powershell and Powershell Workflow scripts on Azure Runbook.
Unable to connect to the remote server (Unable to connect to the ...
0
votes
1
answer
192
views
UNC error on a powershell workflow
When I run the following powershell workflow :
Function Start-LocalRScript {
Param([Parameter(ValueFromPipeline, Mandatory)]$Name)
$ScriptPath = "C:\Exploration.RScripts"
$RScriptExePath = "C:\...
1
vote
0
answers
2k
views
Powershell resume script after reboot using workflow
I'm trying to make a script that continues after a reboot. In short the script is there to deploy a PC for in the field use so the script runs local on a local machine, ideally from a thumb drive. A ...
0
votes
2
answers
1k
views
powershell -parallel not working
I am writing a PowerShell script to display the status of free space and CPU, below is snippet:
function Get_FreeSpace ($authType, $comp) {
$freespace = Invoke-Command -ScriptBlock {
Get-...
1
vote
1
answer
4k
views
Write-Host fails in Invoke-Command in InlineScript in Workflow
I have something like this:
workflow WF {
foreach -Parallel ($computer in $computers) {
$results = InlineScript {
$session = New-PSSession -ComputerName $Using:computer
...
1
vote
0
answers
372
views
Starting Azure Vm in parallel with runbook throws InvalidOperationException
I'm trying to use Azure runbooks to start virtual machines with a specified tag. I use powershell workflow so i can start them i parallel.
The code below works, but it always have problem starting ...
1
vote
0
answers
128
views
PESTER - can i use it for powershell workflows?
Friends,
I am automating some infra related stuffs using powershell and converting that to workflows and running in SMA (Service Management Automation).
Lets say if I have to automate some linux and ...
1
vote
3
answers
4k
views
Running a power shell script in Azure
Hi there I'm new to running powershell scripts in azure and looking for the best guidance ?
I have created a powershell script to locate running machines in a resource group and output to a text file,...
3
votes
0
answers
2k
views
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 ...
3
votes
3
answers
842
views
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)
{
.. ...
1
vote
0
answers
629
views
ADDSForrest installation script won't reboot after completion
Before you try to respond to the title
I am using the -force and the -confirm:$false arguments.
I have been tasked with writing a script that will completely automate the promotion of a server to a ...
6
votes
2
answers
10k
views
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
0
votes
0
answers
249
views
Passing an array of json objects from one powershell workflow to another
I want to pass $output, which is an array of json objects into $json which is an array of json objects in mod3, which is a powershell workflow. I am using this code, but it always results in an error:
...
5
votes
2
answers
5k
views
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.
...
0
votes
1
answer
160
views
Running parallel tests using mstest with PowerShell workflow
A newbie and first question on this forum. My first script successfully runs tests in parallel using mstest with PowerShell v4.0 workflow. But as "InlineScript" has the limitation of running 5 in ...