Skip to content

Commit 98a1ccf

Browse files
authored
Add files via upload
1 parent d4ae766 commit 98a1ccf

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

Get-Query/Get-Query.psm1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function Get-Query ($srv="localhost") {
2+
<#
3+
.SYNOPSIS
4+
Module using query.exe for created object powershell
5+
Does not depend on the localization of the OS
6+
.DESCRIPTION
7+
Example:
8+
Get-Query localhost # default
9+
Get-Query 192.168.1.1
10+
.LINK
11+
https://github.com/Lifailon/Get-Query
12+
https://github.com/Lifailon/Remote-Shadow-Administrator
13+
#>
14+
$Users = New-Object System.Collections.Generic.List[System.Object]
15+
$query = query user /server:$srv
16+
if ($query -ne $null) {
17+
$usr = $query[1..100]
18+
$usr = $usr -replace "^\s"
19+
$usr = $usr -replace "\s{2,100}"," "
20+
$split1 = $usr -split "\n"
21+
foreach ($s in $split1) {
22+
$split2 = $s -split "\s"
23+
if ($split2.Count -eq 6) {
24+
$Users.Add([PSCustomObject]@{
25+
Users = $split2[0]
26+
Session = $null
27+
ID = $split2[1]
28+
Status = $split2[2]
29+
IdleTime = $split2[3]
30+
LogonTime = $split2[4]+" "+$split2[5]
31+
})
32+
}
33+
if ($split2.Count -eq 7) {
34+
$Users.Add([PSCustomObject]@{
35+
User = $split2[0]
36+
Session = $split2[1]
37+
ID = $split2[2]
38+
Status = $split2[3]
39+
IdleTime = $split2[4]
40+
LogonTime = $split2[5]+" "+$split2[6]
41+
})
42+
}
43+
}
44+
$Users
45+
}
46+
}

Screen/Get-Query-EN.jpg

831 KB
Loading

Screen/Get-Query-RU.jpg

1.17 MB
Loading

0 commit comments

Comments
 (0)