Skip to content

Instantly share code, notes, and snippets.

@markgodiy
markgodiy / DblClick-Execute-Powershell-UAC.vbs
Created January 13, 2023 23:00
Execute Powershell Script using VBA, with UAC for Security. To use this script as-is, .vbs file must be in the same folder as .ps1 file, then create shortcut to .vbs file as needed.
Function RunAsAdmin()
Dim objAPP
If WScript.Arguments.length = 0 Then
Set objAPP = CreateObject("Shell.Application")
objAPP.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " RunAsAdministrator",,"runas", 1
WScript.Quit
End If
End Function
@markgodiy
markgodiy / DblClick-Execute-Powershell.wsf
Last active January 13, 2023 23:03
Write PowerShell code within a windows scripting file (.wsf) script. Useful for PowerShell GUI, and scripts that do not require elevated privileges.
<script language="VBScript">
'<![CDATA[
'// CDATA encapsulation is required for powershell to parse this file correctly as XML
'CreateObject("WScript.Shell").Run "powershell -noexit -windowstyle hidden -command ""([xml](Get-Content '" & WScript.ScriptFullName & "')).job.powershell | Invoke-Expression"""
If CreateObject("WScript.Shell").Run("powershell -noexit -command ""([xml](Get-Content '" & WScript.ScriptFullName & "')).job.powershell.'#cdata-section' | Invoke-Expression""",2, False) Then
MsgBox "Script failed to run."
End If
function Set-Lab-RemoteHostsFile {
<#
.EXAMPLE
Set-Lab-RemoteHostsFile -ComputerName <RemoteHostname> -InsertIP "214.47.x.x" -InsertDescription "RemoteServer"
#>
param(
[string]$ComputerName,
Function ZebraTCPClient {
<#
Source/Crecit: Sven Sperner, https://github.com/sperner
Original Code Permalink:
https://github.com/sperner/PowerShell/blob/8c661ec4d0914b02095ffabb7c9dcbd8b1f0185a/TcpClient.ps1
.DESCRIPTION
-To use, load function into a powershell session console.
-Default port is 9100. Zebra printers also uses port 6101.
@markgodiy
markgodiy / James_PrinterMapper
Created April 4, 2023 17:42
James_PrinterMapper
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(600, 400)
############################################## Start functions
# Function to return the name of the selected snaphsot from the second DropDown box
$Global:PrintServer = ""
function FetchPrinters {
$printerTxtFileLocation = 'C:\Temp\PrinterList.txt'
# $Global:PrintServer = $Global:DropDownBox1.SelectedItem.ToString()
Get-Printer -ComputerName "bamcpsvip" | where {$_.Name -like "bamc_h_lab*"} | Select-Object -ExpandProperty Name | Sort-Object -CaseSensitive | Out-File "$printerTxtFileLocation" -Force
@markgodiy
markgodiy / PsGUI_xaml_datagrid_tutorial.md
Last active April 22, 2023 16:16
Powershell XAML GUI tutorial with Datagrid, Textbox, Button, Labels
@markgodiy
markgodiy / gist:7f30f97b4c2da4d3354632652b7caa05
Created July 14, 2023 18:36
WIP-Test-HP-HTTPWebRequest.ps1
$printerIP = <IPaddrr>
# $firmwareFilePath = "C:\path\to\ljM506_fs3.9.12_fw_2309088_001464.bdl"
$policyType = [System.AppDomain]::CurrentDomain.GetAssemblies() |
ForEach-Object { $_.GetTypes() } |
Where-Object { $_.Name -eq 'TrustAllCertsPolicy' }
if (-not $policyType) {
$code = @"
using System.Net;
@markgodiy
markgodiy / Get-SCCMPendingPatches.ps1
Created August 21, 2023 13:06
Get-SCCMPendingPatches
<#
.DESCRIPTION
Author: Mark Go
PowerShell script designed to check for pending patches available via SCCM (System Center Configuration Manager). It provides the ability to retrieve pending patch information for specified remote computers and can be used to identify patches that need to be installed. The script also includes the option to automatically start the WinRM service on target hosts if necessary.
.EXAMPLE
Get-SCCMPendingPatches SERVER01 -Verbose
Get pending patches for a specific computer
@markgodiy
markgodiy / cndcompanionhashtables.txt
Created November 14, 2023 19:41
cndcompanionhashtables.txt
$WingetCommonID = @{
"Google Chrome" = "Google.Chrome"
"Microsoft Edge" = "Microsoft.Edge"
"Mozilla Firefox" = "Mozilla.Firefox"
"Adobe Acrobat Reader DC x64" = "Adobe.Acrobat.Reader.64-bit"
"Adobe Acrobat Reader DC x32" = "Adobe.Acrobat.Reader.32-bit"
"Visual Studio Code" = "Microsoft.VisualStudioCode"
"Microsoft SQL Server" = "Microsoft.SQLServer"
}