Skip to content

Commit

Permalink
Revised for Production
Browse files Browse the repository at this point in the history
  • Loading branch information
VertigoRay committed Jul 22, 2018
1 parent 10cea36 commit 2276119
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
PSGalleryApiKey:
secure: Xpt1sogACnm41S2/1LmhjIl1zn/s1u1dcwNdhLcUh8RA8eOSGaMGB8Ce8B5svBzg
CODECOV_TOKEN:
secure: W18DapjYmwNINy8gyLl30FmNUIzLYE9K2hAMZhE3FJpa/ObmvB5t1d/xxgD0cn+R
secure: 8XE8s/9uWz4uHhsvBGQIiVG4NUpEa80Czhfk4X6NPjwCwyx0AQHs/8Mbm5T5uTzG



Expand Down
14 changes: 2 additions & 12 deletions QuserObject/Private/ConvertTo-QuserObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
This is the MAIN script. This script watches for events and sends found events to Invoke-LMEvent for handling.
.Parameter LicenseManager
.Parameter QuserOutput
A JSON hashtable of processes to concurrency maximum.
Example: '{"DirectoryPath":"\\\\license\\LicenseManager","Processes":{"notepad.exe":5,"Calculator.exe":10}}'
Done this way so we can use the default of setting this as an Environment Variable for the system. Here's the example, but a little easier to read:
{
"DirectoryPath": "\\\\license\\LicenseManager",
"Processes": {
"notepad.exe": 5,
"Calculator.exe": 10
}
}
The number with the process name is the concurrency count.
This is the STDOUT as returned by `quser.exe`.
#>
function ConvertTo-QuserObject {
[CmdletBinding()]
Expand Down
18 changes: 9 additions & 9 deletions QuserObject/Public/Get-Quser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
.Example
Get-QuserObject
Get-Quser
.Example
Get-QuserObject -ServerName 'ThisServer'
Get-Quser -ServerName 'ThisServer'
.Example
Get-QuserObject -ServerName 'ThisServer', 'ThatServer'
Get-Quser -ServerName 'ThisServer', 'ThatServer'
.Example
Get-ADComputer 'ThisServer' | Get-QuserObject
Get-ADComputer 'ThisServer' | Get-Quser
#>
function Get-Quser {
[CmdletBinding(DefaultParameterSetName = 'ServerName')]
Expand All @@ -58,18 +58,18 @@ function Get-Quser {

[Parameter(ParameterSetName = 'ADComputer')]
[ValidateNotNullOrEmpty()]
[PSObject]
[string]
$Property = 'Name'
)

begin {
Write-Debug "[QuserObject Get-QuserObject] Begin Bound Parameters: $($MyInvocation.BoundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-QuserObject] Begin Unbound Parameters: $($MyInvocation.UnboundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-Quser] Begin Bound Parameters: $($MyInvocation.BoundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-Quser] Begin Unbound Parameters: $($MyInvocation.UnboundParameters | ConvertTo-Json)"
}

process {
Write-Debug "[QuserObject Get-QuserObject] Process Bound Parameters: $($MyInvocation.BoundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-QuserObject] Process Unbound Parameters: $($MyInvocation.UnboundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-Quser] Process Bound Parameters: $($MyInvocation.BoundParameters | ConvertTo-Json)"
Write-Debug "[QuserObject Get-Quser] Process Unbound Parameters: $($MyInvocation.UnboundParameters | ConvertTo-Json)"

if ($ServerName) {
$ServerName | Invoke-Quser | ConvertTo-QuserObject
Expand Down
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
Query `quser.exe` and return a proper PowerShell Object.
[![Build status](https://ci.appveyor.com/api/projects/status/d88b15ilqgkqgo4e?svg=true)](https://ci.appveyor.com/project/VertigoRay/quserobject)
[![codecov](https://codecov.io/gh/UNT-CAS/QuserObject/branch/master/graph/badge.svg)](https://codecov.io/gh/UNT-CAS/QuserObject)
[![version](https://img.shields.io/powershellgallery/v/QuserObject.svg)](https://www.powershellgallery.com/packages/QuserObject)
[![downloads](https://img.shields.io/powershellgallery/dt/QuserObject.svg?label=downloads)](https://www.powershellgallery.com/packages/QuserObject)

Run `quser.exe` and return a proper PowerShell Object.
I discussed this [on my blog](http://blog.vertigion.com/2018/04/27/terminal_server_sessions/?utm_source=github&utm_medium=unt-cas&utm_campaign=quserobject) to enhance [a StackOverflow answer](https://stackoverflow.com/a/49042770/615422).
I thought I'd make this into a PowerShell module for ease of use and distribution.

# Quick Setup

1. Install *QuserObject*: `Install-Module QuserObject`.
2. Import *QuserObject*: `Import-Module QuserObject`.
3. Start *QuserObject*: `Get-Quser`.


# Examples

## Quick Example

This will return the `quser.exe` results for the current computer (aka `localhost`).

```powershell
Get-QuserObject
```

## Target a Server

This will return the `quser.exe` results for `ThisServer`.

```powershell
Get-QuserObject -ServerName 'ThisServer'
```

## Target Multiple Servers

This will return the `quser.exe` results for `ThisServer` and `ThatServer`.

```powershell
Get-QuserObject -ServerName 'ThisServer', 'ThatServer'
```

## Pipeline Multiple Servers

This will return the `quser.exe` results for `ThisServer` and `ThatServer`.

```powershell
@('ThisServer', 'ThatServer') | Get-QuserObject
```

## AD Computer

This will return the `quser.exe` results for `ThisServer`.
The value is piped from a `Get-ADComputer` query.

```powershell
Get-ADComputer 'ThisServer' | Get-QuserObject
```

## AD Computer with Different Property

This will return the `quser.exe` results for `ThisServer`.
This value is piped from a `Get-ADComputer` query and using the AD computer `DNSHostName` property instead of the default `Name` property.

```powershell
Get-ADComputer 'ThisServer' | Get-QuserObject -Property 'DNSHostName'
```

0 comments on commit 2276119

Please sign in to comment.