All Questions
27
questions
0
votes
0
answers
16
views
powershell array of object with dynamic properties outputs only properties from first element [duplicate]
why ? and how to fix this ? how to export to csv file now after export i receive the same as when displaying $res.
$res= @()
$obj = [PSCustomObject]@{}
$obj | Add-Member -MemberType NoteProperty -Name ...
0
votes
1
answer
43
views
How to Include All Properties in GridView Even if They're Absent in Some Objects?
I'm using PowerShell to parse XML content and display the results in a grid view. Here's the code I'm using:
$content = @"
<root>
<obj>
<name>John</name>
...
0
votes
1
answer
183
views
Adding a property that is hidden unless it has a value
I'm adding a class related to software packages. Here is a barebones version for the purposes of this question:
class Package {
$Name; $Latest; $Prerelease
[string]ToString(){ return $this....
0
votes
0
answers
67
views
Creating Events in Powershell
The Task:
I'm writing a script that makes changes to an AD Object (user account) in sequential order:
Name change
Group add
Demographics change
Manager name added
Add email address
The problem:
I ...
0
votes
1
answer
62
views
Text file to Text file String Conversion Using Powershell CSV Objects
I can change the column order of text in a file:
001 AALTON Alan 25 Every Street
002 BROWN James 101 Browns Road
003 CAMPBELL Colin 57 Camp Avenue
to have the first names listed before surnames ...
0
votes
1
answer
361
views
How to Extract string from XML Property
Using PowerShell, I am attempting to extract the contents of Value="" which will either be Production or Training, from a XML file. Here is a snippit of the XML file:
<ParameterGroup ...
1
vote
1
answer
2k
views
Get AD Group Member Groups and Find Those Group Notes in One Query
I would like to find an AD group user's group's that their in and to find what those different group's notes are.
Right now, I'm trying this
Get-ADPrincipalGroupMembership "username" | Get-...
0
votes
1
answer
149
views
How to add another property to the element of array based on mapping
In Powershell I have the following array
foreach ($Record in $Records)
{ write-host $Record
}
@{car=OPEL; count=3}
@{car=BMW; count=2}
@{car=OPEL; count=8}
@{car=AUDI; count=3}
@{car=FORD; count=5}
@{...
0
votes
1
answer
453
views
Possible to sort object by property (descending) and still display corresponding values?
$procs = Get-Process
$procs[0] | GM -MemberType Property
This gives all the properties in ascending order. Now, I'd like to display the properties in descending order but with it's values. It's easy ...
1
vote
1
answer
1k
views
PowerShell object properties recursive
I need a function with the following requirements:
The function is assigned an unknown object. It is not known how many properties and / or sub-objects the object has.
The function then iterates ...
0
votes
1
answer
204
views
powershell compare properties of two network adapters side-by-side
I'm just beginning Powershell, and I want to look at all the properties of two network adapters side-by-side in order to easily see differences.
I've used:
Get-NetAdapter -name "(adapter's name)" | ...
1
vote
0
answers
3k
views
How do you compare two arrays that both have multiple properties and objects in Powershell
I am looking for a way to go through each array in a collection. So I have two csvs that I have imported and I need to compare the data on each.
Sample Array contents From CSV1 (Array is $Collection1)...
1
vote
1
answer
3k
views
Strongly type PS custom object properties
I have been using hash tables to return complex data from functions, and it has worked well, but I would like to have the keys strongly typed, since I have booleans, strings, arrays of strings, ...
2
votes
2
answers
9k
views
How to search an object for a value?
Let's say you have a giant object - one which may or may not have nested arrays / objects,
# Assuming 'user1' exists in the current domain
$obj = Get-ADUser 'user1' -Properties *
and I want to ...
0
votes
1
answer
2k
views
How to check if an object member exists in array by property?
Can't get my head around how to check if an object member exists in array by property.
I have the following object:
PS> $siteUser
Id Title LoginName ...