Skip to content

Instantly share code, notes, and snippets.

MyITGuy

Block or report user

Report or block MyITGuy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Test-DotNetAssembly.ps1
#region Test-DotNetAssembly
# If an assembly has been loaded prior to the environment this function is executed in, a new environment is required.
function Test-DotNetAssembly {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string[]]
$InputObject
)
View Get-AltirisDeploymentAgentConfig.ps1
#region Get-AltirisDeploymentAgentConfig
function Get-AltirisDeploymentAgentConfig {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[string]
$ComputerName
)
begin {
View example01.ps1
# Demonstates Write-Output writing blank lines in the console
# This is visible with Write-Host and Write-Verbose
1..3 | ForEach-Object {
$Properties = @{
Name = "Iteration" + $_
}
$obj = New-Object -TypeName psobject -Property $Properties
if ($_ -eq 1) {
Write-Host "↓↓ [$($Properties.Name)] Write-Output writes blank line(s) for first object due to writing header row(s) ↓↓"
}
@MyITGuy
MyITGuy / Get-AccessDefaultIconPath.ps1
Created Sep 17, 2019
Used to capture the path of the default icon for the installation of Microsoft Access. This can then be used with ConvertFrom-OfficeProductCode to determine the Microsoft Access installation type (full vs. runtime, etc.)
View Get-AccessDefaultIconPath.ps1
function Get-AccessDefaultIconPath {
[CmdletBinding(SupportsShouldProcess = $True, DefaultParameterSetName = "None")]
PARAM(
[string]
$ComputerName
)
try {
if ($ComputerName) {
$key = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $ComputerName)
@MyITGuy
MyITGuy / Test-ComObject01.ps1
Last active Sep 17, 2019
Use PowerShell to test for the existence of a COM Object.
View Test-ComObject01.ps1
#region Test-ComObject
function Test-ComObject {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[string]
$ComputerName = $env:COMPUTERNAME
,
[Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)]
[string]
View Get-DismWindowsFeature.ps1
#region Get-DismWindowsFeature
function Get-DismWindowsFeature {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[string]
$Name
,
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[switch]
@MyITGuy
MyITGuy / Bluetooth.psm1
Last active Aug 22, 2019
Turn Bluetooth on/off or reset. Set-Bluetooth Disable-Bluetooth Enable-Bluetooth Reset-Bluetooth
View Bluetooth.psm1
function Set-Bluetooth {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[ValidateSet('On', 'Off', 'Reset')]
[string]
$State
)
begin {
Add-Type -AssemblyName System.Runtime.WindowsRuntime
@MyITGuy
MyITGuy / Stop-Pipeline.ps1
Last active Aug 16, 2019
An *unhandled exception' is encountered when using **break** within a **ForEeach** within a *System.Windows.Forms.Form* within PowerShell. As a workaround, using this CmdLet will stop the current pipeline instead of using **break**. [PS Forms - Unha
View Stop-Pipeline.ps1
filter Stop-Pipeline {
#requires -version 3
# PS Bug: PS Forms - Unhandled Exception using BREAK in ForEach loop, https://stackoverflow.com/questions/54331852/ps-forms-unhandled-exception-using-break-in-foreach-loop
$SteppablePipeline = { Select-Object -First 1 }.GetSteppablePipeline($MyInvocation.CommandOrigin)
$SteppablePipeline.Begin($true)
$SteppablePipeline.Process(0)
}
View Get-WindowsNetworkProvider.ps1
#region Get-WindowsNetworkProvider
function Get-WindowsNetworkProvider {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[string[]]
$Name
)
begin {
View Clear-AppVO365DocToIdMappingSearchQueries.ps1
#region Clear-AppVO365DocToIdMappingSearchQueries
function Clear-AppVO365DocToIdMappingSearchQueries {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
[System.Guid[]]
$PackageId = @("EB51A3D4-B87F-4676-AD01-5D583ABE053C")
,
[switch]
$Analyze
You can’t perform that action at this time.