Fix Get-NetSession

Fixes Computer typo to ComputerName in NetSessionEnum, null out user first prior to passing
This commit is contained in:
Matt Kelly 2017-10-17 17:53:04 -05:00 committed by GitHub
parent 50e18ef8ab
commit 4d69fe972a
1 changed files with 4 additions and 2 deletions

View File

@ -15009,9 +15009,11 @@ http://www.powershellmagazine.com/2014/09/25/easily-defining-enums-structs-and-w
$EntriesRead = 0
$TotalRead = 0
$ResumeHandle = 0
#Null username first prior to passing to NetSessionEnum API
$UserName = ''
# get session information
$Result = $Netapi32::NetSessionEnum($Computer, '', $UserName, $QueryLevel, [ref]$PtrInfo, -1, [ref]$EntriesRead, [ref]$TotalRead, [ref]$ResumeHandle)
$Result = $Netapi32::NetSessionEnum($ComputerName, '', $UserName, $QueryLevel, [ref]$PtrInfo, -1, [ref]$EntriesRead, [ref]$TotalRead, [ref]$ResumeHandle)
# locate the offset of the initial intPtr
$Offset = $PtrInfo.ToInt64()