Skip to content

Commit

Permalink
Merge pull request #461 from TheJumpCloud/SA-3135_runAsUserCommandUpdate
Browse files Browse the repository at this point in the history
check nuget before runasuser
  • Loading branch information
jworkmanjc authored Jan 26, 2023
2 parents 031affe + 50930b3 commit 5218306
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ windows
#### Command

```
# If Nuget is not installed, go ahead and install it
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PkgProvider = Get-PackageProvider
If ("Nuget" -notin $PkgProvider.Name){
Install-PackageProvider -Name NuGet -Force
}
# If PSModule RunAsUser is not installed, install it
if ( -not (get-installedModule "RunAsUser" -ErrorAction SilentlyContinue)) {
install-module RunAsUser -force
Expand All @@ -27,9 +34,9 @@ This template can be modified to target a command to run as the signed in user c

Before running this command the **$Command** block must be populated.

An example of this command is if ```C:\windows\system32\notepad.exe``` is placed in the command block and executed against a system that has a signed in user session. Notepad will launch and show up for the signed in user. This will also work if the session is locked but still signed in. It however can only work when there is one signed in session like on most workstation SKU's of Windows.
An example of this command is if `C:\windows\system32\notepad.exe` is placed in the command block and executed against a system that has a signed in user session. Notepad will launch and show up for the signed in user. This will also work if the session is locked but still signed in. It however can only work when there is one signed in session like on most workstation SKU's of Windows.

#### *Import This Command*
#### _Import This Command_

To import this command into your JumpCloud tenant run the below command using the [JumpCloud PowerShell Module](https://github.com/TheJumpCloud/support/wiki/Installing-the-JumpCloud-PowerShell-Module)

Expand All @@ -39,6 +46,8 @@ Import-JCCommand -URL "https://github.com/TheJumpCloud/support/blob/master/Power

#### Usage Notes

For module usage and license information, please visit the [runAsUser GitHub Project Page](https://github.com/KelvinTegelaar/RunAsUser)

From the module readme:

> When you execute invoke-ascurrentuser the command will always return the PID of the process it ran/is running in.
Expand All @@ -59,7 +68,13 @@ if (-not(Test-Path -Path $outfile -PathType Leaf)) {
catch {
throw $_.Exception.Message
}
}
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# If Nuget is not installed, go ahead and install it
$PkgProvider = Get-PackageProvider
If ("Nuget" -notin $PkgProvider.Name){
Install-PackageProvider -Name NuGet -Force
}
# If PSModule RunAsUser is not installed, install it
if ( -not (get-installedModule "RunAsUser" -ErrorAction SilentlyContinue)) {
Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Commands Gallery/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@
{
"name": "Windows - Run As Signed In User Template | v1.1 JCCG",
"type": "windows",
"command": "# If PSModule RunAsUser is not installed, install it\nif ( -not (get-installedModule \"RunAsUser\" -ErrorAction SilentlyContinue)) {\n install-module RunAsUser -force\n}\n\n$Command = {\n #Powershell Command Goes Here.\n}\n\ninvoke-ascurrentuser -scriptblock $Command",
"command": "# If Nuget is not installed, go ahead and install it\n[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\n$PkgProvider = Get-PackageProvider\nIf (\"Nuget\" -notin $PkgProvider.Name){\n Install-PackageProvider -Name NuGet -Force\n}\n\n# If PSModule RunAsUser is not installed, install it\nif ( -not (get-installedModule \"RunAsUser\" -ErrorAction SilentlyContinue)) {\n install-module RunAsUser -force\n}\n\n$Command = {\n #Powershell Command Goes Here.\n}\n\ninvoke-ascurrentuser -scriptblock $Command",
"link": "https://github.com/TheJumpCloud/support/blob/master/PowerShell/JumpCloud%20Commands%20Gallery/Windows%20Commands/Windows%20-%20Run%20As%20Signed%20In%20User%20Template.md",
"description": "This template can be modified to target a command to run as the signed in user context of a system. The Jumpcloud agent cmd runner executes as NTAuthority\\System and therefore can not interact with the signed in user session on a computer. This template and accompanying Powershell Module code from https://github.com/KelvinTegelaar/RunAsUser allows the Command block to be run as the signed in user session.\n\nBefore running this command the **$Command** block must be populated.\n\nAn example of this command is if ```C:\\windows\\system32\\notepad.exe``` is placed in the command block and executed against a system that has a signed in user session. Notepad will launch and show up for the signed in user. This will also work if the session is locked but still signed in. It however can only work when there is one signed in session like on most workstation SKU's of Windows."
"description": "This template can be modified to target a command to run as the signed in user context of a system. The Jumpcloud agent cmd runner executes as NTAuthority\\System and therefore can not interact with the signed in user session on a computer. This template and accompanying Powershell Module code from https://github.com/KelvinTegelaar/RunAsUser allows the Command block to be run as the signed in user session.\n\nBefore running this command the **$Command** block must be populated.\n\nAn example of this command is if `C:\\windows\\system32\\notepad.exe` is placed in the command block and executed against a system that has a signed in user session. Notepad will launch and show up for the signed in user. This will also work if the session is locked but still signed in. It however can only work when there is one signed in session like on most workstation SKU's of Windows."
},
{
"name": "Windows - Send Notification Message | JCCG v1.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/authentication_examples/ldap/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
highline (1.7.10)
net-ldap (0.16.1)
net-ldap (0.16.2)

PLATFORMS
ruby
Expand Down

0 comments on commit 5218306

Please sign in to comment.