This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Provider | |
using namespace System.Management.Automation.Runspaces | |
[CmdletProvider('MyProvider', [ProviderCapabilities]::None)] | |
class Provider : DriveCmdletProvider { | |
[PSDriveInfo] NewDrive( [PSDriveInfo]$drive ) | |
{ | |
return ([DriveCmdletProvider]$this).NewDrive($drive) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SqlVersionName { | |
param( | |
[Version]$Version | |
) | |
$lookup = @{ | |
'Name' = ('Major', 'Minor', 'RTM', 'SP1', 'SP2', 'SP3', 'SP4') | |
'2016' = ( 13, 0, 1601, 4001 ) | |
'2014' = ( 12, 0, 2000, 4100, 5000 ) | |
'2012' = ( 11, 0, 2100, 3000, 5058, 6020 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter Write-String { | |
<# | |
.SYNOPSIS | |
Write a string representation of an object. | |
.DESCRIPTION | |
Write-String creates formatted string representations of an input object. | |
.INPUTS | |
System.Object | |
.EXAMPLE | |
Get-Process | Write-String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Password { | |
<# | |
.SYNOPSIS | |
Generate a random password. | |
.DESCRIPTION | |
Generate a random password. | |
.NOTES | |
Change log: | |
27/11/2017 - faustonascimento - Swapped Get-Random for System.Random. | |
Swapped Sort-Object for Fisher-Yates shuffle. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
using namespace System.Reflection | |
function Get-FunctionInfo { | |
<# | |
.SYNOPSIS | |
Get an instance of FunctionInfo. | |
.DESCRIPTION | |
FunctionInfo does not present a public constructor. This function calls an internal / private constructor on FunctionInfo to create a description of a function from a script block or file containing one or more functions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName PresentationFramework | |
[Xml]$xaml = '<?xml version="1.0" encoding="utf-8"?> | |
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Height="500" Width="500"> | |
<DockPanel> | |
<Label Content="Title" DockPanel.Dock="Top" /> | |
<Label Content="Copyright" Margin="5" DockPanel.Dock="Bottom" /> | |
<StackPanel DockPanel.Dock="Left"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum UserRight { | |
SeAssignPrimaryTokenPrivilege # Replace a process level token | |
SeAuditPrivilege # Generate security audits | |
SeBackupPrivilege # Back up files and directories | |
SeBatchLogonRight # Log on as a batch job | |
SeChangeNotifyPrivilege # Bypass traverse checking | |
SeCreateGlobalPrivilege # Create global objects | |
SeCreatePagefilePrivilege # Create a pagefile | |
SeCreatePermanentPrivilege # Create permanent shared objects | |
SeCreateSymbolicLinkPrivilege # Create symbolic links |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-Service { | |
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByName')] | |
param ( | |
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'ByName')] | |
[String]$Name, | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'FromPipeline')] | |
[PSTypeName('Microsoft.Management.Infrastructure.CimInstance#root/cimv2/Win32_Service')] | |
[CimInstance]$InputObject, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-DynamicModuleBuilder { | |
<# | |
.SYNOPSIS | |
Creates a new assembly and a dynamic module within the current AppDomain. | |
.DESCRIPTION | |
Prepares a System.Reflection.Emit.ModuleBuilder class to allow construction of dynamic types. The ModuleBuilder is created to allow the creation of multiple types under a single assembly. | |
.EXAMPLE | |
New-DynamicModuleBuilder | |
#> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Resolve-ParameterSet { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[String]$Command, | |
[String[]]$ParameterName | |
) | |
try { |
OlderNewer