All Questions
Tagged with powershell arrays
2,168
questions
0
votes
1
answer
39
views
Powershell - flatten out array with multiple values in multiple subarrays
When I run the API call below, I get the following result as a single line array.
service : Test-Change
name : svrtest
resource : server:domain:...
1
vote
3
answers
64
views
Powershell: Replacing string elements in the hashtable
I have the following Hashtable ($wImages):
Name Value
---- -----
abc.png 1
def.png 1
ghk.png 1
xyz.png 1
I want to ...
0
votes
2
answers
74
views
Powershell : Compare an Hashtable to multiple System.Object and return only the matching one
I'm trying to compare an hashtable to multiple output from Pipeline, in he shortest way ( one line if possible).
Each output will contains at minimum same Property as Key in hashtable, but could have ...
0
votes
0
answers
44
views
Powershell array of strings into single sql column
I've this array of strings:
$qLastSS_T
2024-07-08 11:56:32
2024-08-08 12:56:32
2024-09-08 13:56:32
2024-10-08 13:56:32
2024-11-08 15:56:32
2024-12-08 16:56:32
and a sql table like this:
It's ...
2
votes
0
answers
56
views
How does a string unexpectedly become an array?
In one of my script I have the following problem: assigning to a string variable the result of a function makes the string an array. Example:
---------- (function edited for clarity)
$x=""
...
3
votes
1
answer
40
views
Powershell: How to add new values to an array
I have an Netapp .csv containing volume names, size, etc. and I'm importing this into an Powershell array $volumes.
I'm filtering the stuff I need:
$volumes | select Name,"Storage VM",...
0
votes
1
answer
43
views
How do I format ImageMagick argument for Powershell script (array of points for drawing intersecting lines connecting hexagonal vertices)?
I'm trying to set up a project to interest nephew in design/coding (while learning myself). This snippet appears to work, but it's suboptimal and I can't figure out how to set $draw as array and call ...
1
vote
2
answers
40
views
What kind of arrays can be considered as Null array in Powershell or how to declare a Null array?
I defined an array as below:
$array =@($null)
On comparing this array with $null the output suggests it's not null
if($null -eq $array)
{
'Array is $null'
}
--> Doesn't return any ...
1
vote
1
answer
36
views
Slice of Strings Operation Reports System.Object Array Conversion Error
When attempting to replace values in a slice of a string array I am getting this error
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System....
0
votes
1
answer
36
views
Powershell: Create valid json file from object in array
I get all group names and the names of the "managedBy" field from AD. I want that output to export to an valid json file.
But my json isn't in a valid format, the brackets ([]) and the comma ...
1
vote
2
answers
53
views
Testing if a value is in an array with a wildcard
I have this value: $ArrVar_ASP=@("Adobe*","UXP WebView Support")
$($pre.DisplayName) --> Adobe Acrobat (64-bit)
If ($($pre.DisplayName) -notin $ArrVar_ASP) {$...
1
vote
1
answer
40
views
How to pass a string array to a pipeline function in Powershell?
My function builds a representation of a table as a PSCustomObject. It has a title, an array of column headers, and a [System.Collection.Generic.List][string] of rows:
function Create-ConfluenceTable{...
0
votes
0
answers
24
views
How do I select(?) an element in a 3D array and place the appropriate elements into another array? Powershell
Here is a portion of the code.
$importData = @()
for ($i = 0; $i -lt $importData1.Count; $i++) {
Write-Host "Debug: Variable `$i is $i"
switch -Regex ($importData1.Vlan[$i]) {
...
0
votes
0
answers
25
views
How to convert a changing text file to json with correct formatting. Data will displayed as a HTML
I have a PowerShell script that prints out the following information as a text file.
I converted that text file as a json file which I Can index however, the goal is to convert this data into a HTML ...
1
vote
3
answers
49
views
Add items to an PowerShell array, and process the array in batches [duplicate]
I have an array with strings:
$Names = @("Name1","Name2","Name3","Name4","Name5","Name6","Name7","Name8","Name9&...