All Questions
27 questions
1
vote
0
answers
15
views
Convert String to Array of Objects in PowerShell [duplicate]
I have an array of strings that I need to convert to array of objects.
Here is an example:
PS C:\Windows\system32> $datasets[0]
id : 11111
name ...
1
vote
3
answers
1k
views
Powershell split an array into 5 arrays with equal length
Hello everyone hope you are all doing great! been searching but cannot get it right :( could it be possible for you to help me, please?
Need to split an array into 5 arrays with equal length, for ...
0
votes
0
answers
273
views
PowerShell : Add New Key Value Pair In JSON File
I want to add new key value in existing parsed json after specific index. For example : I have imported json in $json variable and then I wanted to add new property right after property name 'Service1'...
1
vote
1
answer
734
views
Powershell - Get value from JSON using string from array [duplicate]
What im trying to do is getting one specific value from nested JSON. Using array keys as expression.
Array with keys and values:
$AccountService = @{
'root.branch.setting1'= 'Val1'
'root....
0
votes
1
answer
1k
views
Sending email with Powershell from csv list
I have a *.csv file with a few columns and I want to use the UsersTo and UsersCc list of users to send messages.
The problem is with $CcAddress as I have multiple email address once I format them I ...
1
vote
1
answer
517
views
HTML formatted report – email via PowerShell
Use case:
Generate AD Account created in the last 30 days
Export to as Csv or txt
Import data into html formatted report email to sysAdmin
Issue: Received email with all row data showing as: System....
2
votes
4
answers
2k
views
Create and split an array twice all inline in Powershell
I have the following code which works but I am looking for a way to do this all inline without the need for creating the unnecessary variables $myArray1 and $myArray2:
$line = "20190208 10:05:00,...
1
vote
3
answers
969
views
How to read the first element of all Rows in a text file and then iterate over it in Powershell scripting?
I am a complete newbie in Powershell scripting and programming. I need to do the Following:
There is text file which has number of rows, each row has elements separated by commas. Now, some rows ...
0
votes
1
answer
4k
views
how to convert array of string in json to array of strings in powershell?
I have below json
{
"abc": [
{ "def": [ "", "" ] },
{ "ghi": [ "", "" ] },
{ "xyz" : ["\\[dbo\\].\\[abc1\\]", "\\[dbo\\].\\[def1\\]"] }
]
}
i want to read this json and convert string ...
0
votes
1
answer
4k
views
Use txt file as list in PowerShell array/variable
I've got a script that searches for a string ("End program" in this case). It then goes through each file within the folder and outputs any files not containing the string.
It works perfectly when ...
0
votes
1
answer
91
views
Unable to sort a 2D array in powershell
I'm getting some unique results with this little guy
clear
$Datas = @{}
$Datas["Database1"] = "440"
$Datas["Database2"] = "140"
$Datas["Database3"] = "210"
$Datas | sort value
The Results are:
Name ...
0
votes
3
answers
2k
views
How to search a collection with an array in Powershell
I have an array of MailItems from Outlook. I want to search each mail item and return the Subject and a Category based on a list of search terms contained in an array - in the example called $...
0
votes
1
answer
48
views
Arrays / CustomObjects
TL;DR: I'm trying to build an array with headers based off a condition, ideally looking like this.
Name Value Status
Element 1 Value 1 --
Element 2 Value 2 Action ...
0
votes
2
answers
187
views
Assign all child paths in the parent directory to an array
I am trying to assign all child paths of files in a directory to an array but not assigning the directories.
I am using the following command:
$a = Get-ChildItem -path "C:\test\" -recurse | ?{!$_....
-1
votes
1
answer
400
views
Foreach looping data in a array to check against items in another array
I've tried many variations but I am unable to pass the value from one foreach to another foreach loop. I am trying to parse through event logs for login logout info and then create a CSV file for each ...