This repository was archived by the owner on Jan 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathremoting.ps1
More file actions
57 lines (40 loc) · 1.52 KB
/
remoting.ps1
File metadata and controls
57 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Function Get-Info {
[string]$hostname = hostname
$adpcArray = @()
$adpc = Get-ADComputer -Filter * | Select Name
$adpc | foreach-object { $adpcArray += $_.Name }
$adpcList = {$adpcArray}.Invoke()
$adpcList.Remove($hostname.ToUpper()) | Out-Null
$computers = $adpcList
# Instantiate the array for the objects
$output = @();
# Loop through all $computers in $hostname file
foreach($entry in $computers) {
# Let's create a complex object with an array as a property
$psversions = invoke-command $entry {$PSVersionTable}
$psversion = @()
foreach ($p in $psversions) {
$psobject = [pscustomobject]@{
PSVersie = $p.PSVersion
WSMANVersie = $p.WSManStackVersion
}
$psversion += $psobject
}
# Collect other info
$info = Get-CimInstance -Classname Win32_OperatingSystem -Computername $entry
$bios = Get-CimInstance -Classname Win32_Bios -Computername $entry
# create the object for reporting
$object = [pscustomobject]@{
hostname = $info.PSComputerName;
os = $info.caption;
fabrikant = $bios.manufacturer;
serial = $info.serialnumber;
registratienaam = $info.registereduser;
datum = (Get-Date);
company = 'Contoso';
powershell = $psversion;
}
$output += $object
}
Write-Output $output
}