Skip to content

Instantly share code, notes, and snippets.

View martin77s's full-sized avatar

Martin Schvartzman martin77s

View GitHub Profile
@martin77s
martin77s / Add-ShareAccess.ps1
Created February 15, 2018 08:37
Add permissions to an existing share
function Add-ShareAccess {
param(
[string] $ComputerName = $env:COMPUTERNAME,
[string] $ShareName = 'Temp',
[string] $AccountName = 'Domain Users',
[ValidateSet('FullControl', 'Change','Read')] $AccessPermissions = 'Read'
)
# Convert the AccessPermissions
$accessFlags = @{
@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 / Get-CertificateFromCredential.ps1
Last active February 15, 2018 08:34
Get the certificate selected in Get-Credential
function Get-CertificateFromCredential {
param([PSCredential]$Credential)
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public static class NativeMethods {
@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 / Remove-Profile.ps1
Last active October 22, 2018 09:32
Remove Profiles from a local or remote computer
#requires -version 3
function Remove-Profile {
param(
[string[]]$ComputerName = $env:ComputerName,
[pscredential]$Credential = $null,
[string[]]$Name,
[ValidateRange(0,365)][int]$DaysOld = 0,
[string[]]$Exclude,
[switch]$IgnoreLastUseTime,
[switch]$Remove