Skip to content

Instantly share code, notes, and snippets.

@jbratu
jbratu / powershell-non-domain-remoting.md
Created March 26, 2024 16:16 — forked from cmcginty/powershell-non-domain-remoting.md
Windows Powershell Remoting into Non-Domain Joined System

Powershell Remoting to a Non-Domain Host

  1. From an admin shell, enable PS remoting on the machine you wish to access:
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
  -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
  -PropertyType DWord -Value 1

Enable-PsRemoting -Force
@jbratu
jbratu / .bashrc color changes
Created March 31, 2023 17:37
bash color changes
LS_COLORS=$LS_COLORS:'di=0;97;104:' ; export LS_COLORS
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;37m\]\w\[\033[00m\]\$ '
run attach_table "Z:\OpenInsight\datavol", "REVMEDIA", "SYSPROG", ""

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

@jbratu
jbratu / gist:d5e5939b4e2ec2fe9c4f894fe911f36b
Created March 24, 2022 14:21
elevate powershell script
#https://blog.expta.com/2017/03/how-to-self-elevate-powershell-script.html
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
MPR
ULONG STDCALL WNetGetUniversalNameA( LPASTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalNameA
ULONG STDCALL WNetGetUniversalNameW( LPWSTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalNameW
ULONG STDCALL WNetGetUniversalNameW( LPWSTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalName
Overwrite any existing DLL_MPR.
From the system monitor type: run DECLARE_FCNS "DLL_MPR"
Function TEST_REVCAPI(method)
/*
** Purpose: Test calling revCapi
**
** Usage:
** run TEST_REVCAPI 'SUB' to test callsubroutine
** run TEST_REVCAPI 'FUNC' to test callFunction
** run TEST_REVCAPI '' to test CreateRequest
**
@jbratu
jbratu / t_Refresh_blank_rdk.oibp
Created December 21, 2021 13:10
Code from Revelation Software provided as a Works support request when asking how to programatically create an RDK.
subroutine t_Refresh_blank_rdk(void)
/*
** Build rdks identical to what comes from RDK window, so can be installed with RDKINSTALL
** But, uses a list of items stored in SYSLISTS.
**
** Creates RDK as a subfolder In the base folder
** rdk_LIST_ID_yyyymmdd contains all source And executables
*/
$insert Logical
REGEDIT4
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LogMeInInc\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LogMeInInc\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\LogMeInInc\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\LogMeInInc\GoToAssist Express Customer]
Function test_jab(void)
Password = '123456789012345'
Max = 4000
Offset = 0
For i = 1 To Max
Id = i + offset
UserName = 'USER' : Fmt(ID,"R(0)#21")