Skip to content

Instantly share code, notes, and snippets.

@jszabo98
jszabo98 / example.ps1
Last active January 14, 2019 19:59
example powershell colors
# This is a PowerShell comment.
function MyFunction([Parameter(Position = 0)][System.String]$path)
{
:loopLabel foreach ($thisFile in (Get-ChildItem $path))
{
Write-Host ; Write-Host -Fore Yellow `
('Length:' +
[System.Math]::Floor($thisFile.Length / 1000))
}
@jszabo98
jszabo98 / myobject.format.ps1xml
Last active May 31, 2018 00:22
basic format file for a table view of an object with 5 properties
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>myobject</Name>
<ViewSelectedBy>
<TypeName>myobject</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@jszabo98
jszabo98 / acls.ps1
Last active November 27, 2023 23:00
acls powershell
$acl = Get-Acl -Path C:\SpecialFolder\SpecialFile.txt
$user = 'BillB'
$rights = [System.Security.AccessControl.FileSystemRights]'ReadAndExecute, Write, Modify, Read' # enum flags
$rights
Modify
$RuleBillB = [System.Security.AccessControl.FileSystemAccessRule]::new($user, $rights, 'Allow')
$RuleBillB