Skip to main content

All Questions

-1 votes
1 answer
64 views

how to declare Powershell parameter

I have a Powershell function where I am trying to declare some parameter $vipstatus, I mean when I try to execute the function with that parameter I want to see only the result stored in $vipstatus. ...
saravana raj's user avatar
1 vote
0 answers
85 views

Having an options array in a Powershell variable

I am currently adding a Parameter to a script. The outcome I want is that if the script is run manually - that the user will get prompted like this for an input: Press 1 for Option blah Press 2 for ...
TheDemonLord's user avatar
0 votes
1 answer
67 views

PowerShell: Is there a better way to handle passing arrays to another script than what I'm doing?

I'm writing a PowerShell script to create a Windows cluster at AWS. I need to run a script which first retries the domain admin credentials and then passes params to the next script. Involved are 2 ...
TechFA's user avatar
  • 129
3 votes
1 answer
513 views

How to only allow array parameter of a certain length

I'm currently studying advanced functions for my PowerShell module and was tasked with a problem I don't think was properly covered in the class. Here's said problem. Create an advanced function ...
Phynx's user avatar
  • 33
1 vote
2 answers
312 views

Check for use of comma in multiple strings passed as parameters in Powershell

I have a script that takes two parameters: one takes a single string, the other takes two strings. For the script to function correctly both strings have to be separated by a comma. When using the ...
J. Davalos's user avatar
0 votes
1 answer
873 views

How do i pass an array into a function?

I have the following code down below that will take an array and write out the correlating pixel colors to the powershell window. The array itself is to form an image. At this point I just have the ...
I am Jakoby's user avatar
0 votes
1 answer
481 views

[string[]] Parameter vs Read-Host behaviour

Within my PowerShell script I have parameter set for : [string[]]$OptionNum So I can call my script using for instance : .\MyScript.ps1 1,4,6 I then have a switch statement on $OptionNum for PSItem –...
Keith Langmead's user avatar
2 votes
1 answer
365 views

In powershell, how to build String arrays from "remaining" arguments passed from command line? [duplicate]

It is inconvenient to type ("arg0", "arg1", "arg2") on the command line when a function needs a String array. Like in this example: function Exec-GradleScript( [...
Charlweed's user avatar
  • 1,632
1 vote
1 answer
1k views

Powershell script not working without "powershell.exe -File" and it's also not working properly with "powershell.exe -File"

I have the script that works perfectly when run from ISE or VS Code with parameters given in code like param( [string]$Param1 = "example", [string[]]$Param2 = @('arrayparam1','...
Ekrad's user avatar
  • 21
1 vote
1 answer
4k views

Iterate through multiple arrays in powershell script

I am attempting to use multiple arrays to pass multiple server names, and maybe other elements, that maybe be needed in conjunction to each other to a function's set of Parameters in a Powershell ...
echoShib's user avatar
2 votes
3 answers
319 views

How to retain trailing zeros in string array parameter without using quotes

PowerShell drops the trailing zero of an array element's value when that value contains a dot. Unless I wrap the value in quotes. Unfortunately I need to retain the trailing zero and the script users ...
gstratt's user avatar
  • 233
1 vote
4 answers
3k views

Powershell Robocopy - Multiple parameters in a variable

I have a long robocopy string which i want to shorten a bit to make adding more robocopy processes easier for example i have this: robocopy $source $destination /e /XC /XO /xx /tee /MIR /Z /XA:H /W:2 ...
Steven Zheng's user avatar
2 votes
1 answer
2k views

powershell.exe -file string array as parameter

I'm actually writing a plugin with powershell for a monitoring solution. This monitoring solution runs the powershell skript from the command line cmd. One of the input parameters is a string array ...
brunofernandez's user avatar
0 votes
1 answer
3k views

Pass string array as a parameter to a powersell script using Runtime.exec(...)

I need to pass a string array as an argument to a PowerShell script from Java using Runtime.getRuntime().exec(cmd) that array holds some values like: String[] users = new String[] {"Jon", "Adam"}; ...
TENNO's user avatar
  • 165
1 vote
2 answers
62 views

Strange behavior: Input parameter (with multiple values that end with "D" or "L" characters)

I have the following PowerShell function: function Get-Devices { [CmdletBinding()] param( [Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, ...
MKANET's user avatar
  • 663

15 30 50 per page