Skip to content

Instantly share code, notes, and snippets.

View martin77s's full-sized avatar

Martin Schvartzman martin77s

View GitHub Profile
@martin77s
martin77s / Disable-Scripting.FileSystemObject.ps1
Last active February 12, 2020 18:29
Disabling the Scripting.FileSystemObject ComObject (When you get the 0x8002801c error)
#region Helper functions
function Set-Ownership {
[CmdletBinding(SupportsShouldProcess = $false)]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Path,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()] [ValidatePattern('(\w+)\\(\w+)')]
@martin77s
martin77s / DscWithWinRmDisabled.ps1
Last active August 17, 2020 13:55
Using DSC with the WinRM service disabled
#region ### BUILD THE CONFIGURATION ###
# Declare the configuration:
Configuration TestDscWithoutWinRm {
Import-DscResource –ModuleName PSDesiredStateConfiguration
node localhost {
File akada {
Ensure = 'Present'
Type = 'File'
Contents = 'Martin was here!'
@martin77s
martin77s / PowerShellFromBatch.cmd
Last active April 4, 2021 13:35
Embed PowerShell code in a batch file
@ECHO off
@setlocal EnableDelayedExpansion
@goto label1
@echo this lines should not be printed
@echo and this whole block (lines 4-8) can actually be removed
@echo I added these just for Charlie22911
@:label1
@set LF=^
@martin77s
martin77s / New-Share.ps1
Created February 15, 2018 08:35
Create a new share with specific permissions
function New-Share {
param(
[string] $ComputerName = $env:COMPUTERNAME,
[string] $Path = 'C:\Temp',
[string] $ShareName = 'Temp',
[string] $AccountName = 'Domain Users',
[ValidateSet('FullControl', 'Change','Read')] $AccessPermissions = 'Read',
[string] $ShareDescription
)
@martin77s
martin77s / Send-RemoteToastNotification.ps1
Created June 15, 2019 18:52
Send toast notification to a remote computer
PARAM(
$RemoteComputer = $env:COMPUTERNAME,
$Sender,
$Message = (Get-Date),
$ImageFile
)
function New-ToastNotification {
param($Sender, $Message, $ImageBase64)