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
| $serviceVolume = Get-PSDrive -PSProvider 'Microsoft.PowerShell.Core\FileSystem' | ?{$_.Description -eq 'Service Volume'} | |
| $adminProvTool = Join-Path -Path $serviceVolume.Root -ChildPath 'AosService\PackagesLocalDirectory\bin\AdminUserProvisioning.exe' | |
| if (Test-Path -Path $adminProvTool) { | |
| "Admin User Provisioning Tool Found: $adminProvTool" | |
| & $adminProvTool | |
| } else { | |
| Write-Error "Could not find admin user provisitioning tool at: $adminProvTool" | |
| } |
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
| #heavily based on https://gallery.technet.microsoft.com/scriptcenter/Verify-the-Active-021eedea/view/Discussions#content | |
| function Test-ADCredential { | |
| [CmdletBinding()] | |
| Param | |
| ( | |
| [Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
| [System.Management.Automation.Credential()] | |
| [System.Management.Automation.PSCredential]$Credential | |
| ) | |
| begin { |
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
| void Main() | |
| { | |
| using (var thesaurus = new Thesaurus()) | |
| { | |
| foreach (var term in (new string[]{"dictionary","hot","actor","code"})) | |
| { | |
| Debug.WriteLine(term); | |
| foreach (var value in thesaurus.GetSynonyms(term)) | |
| { | |
| Debug.WriteLine($"- {value}"); |
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-MailRecipients { | |
| [CmdletBinding(DefaultParameterSetName = 'ByFilename')] | |
| Param ( | |
| [Parameter(Mandatory = $true, ParameterSetName = 'ByFilename', ValueFromPipeline = $true)] | |
| [string]$Path | |
| , | |
| [Parameter(Mandatory = $false, ParameterSetName = 'ByFilename')] | |
| [PSObject]$Outlook = $null | |
| , | |
| [Parameter(Mandatory = $true, ParameterSetName = 'ByMessage')] |
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()] | |
| Param ( | |
| [Parameter()] | |
| [string]$Name | |
| ) | |
| Process { | |
| #could be improved by implementing everything the full suite of parameters that Start/Stop-Service have; for now just fulfils the most basic requirement | |
| Stop-Service -Name $Name -Force -ErrorAction SilentlyContinue | |
| sc.exe delete $Name |
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 Compress-Guid { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(ValueFromPipeline = $true)] | |
| [Guid]$Guid = [Guid]::NewGuid() | |
| ) | |
| Process { | |
| Write-Verbose "Received Guid $Guid" | |
| [string]$GuidJustTheDigits = ($Guid.ToString() -replace '[{}-]','') #actually we don't need to replace {} since PS defaults to hyphens only formatting; but this does no harm / there's not much additional cost. | |
| Write-Verbose "Just the digits length: $($GuidJustTheDigits.Length)" #32 chars |
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
| cls | |
| [Environment]::SetEnvironmentVariable("MSSQL64",'C:\Program Files\Microsoft SQL Server',"Machine") | |
| [Environment]::SetEnvironmentVariable("MSSQL86",'C:\Program Files (x86)\Microsoft SQL Server',"Machine") | |
| $path = [Environment]::GetEnvironmentVariable("PATH","User") | |
| $path = ($path -replace 'C:\\Program Files\\Microsoft SQL Server\\','%MSSQL64%\') -replace 'C:\\Program Files \(x86\)\\Microsoft SQL Server\\','%MSSQL86%\' | |
| [Environment]::SetEnvironmentVariable("PATH",$path,"User") | |
| $path = [Environment]::GetEnvironmentVariable("PATH","Machine") | |
| $path = ($path -replace 'C:\\Program Files\\Microsoft SQL Server\\','%MSSQL64%\') -replace 'C:\\Program Files \(x86\)\\Microsoft SQL Server\\','%MSSQL86%\' |
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 System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| namespace JohnLBevan.Collections.Generic | |
| { | |
| public class BidirectionalDictionary<T1, T2>: IDictionary<T1, T2> | |
| { | |
| IDictionary<T1, T2> ab; |
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
| /* | |
| A while back I started using classes with static properties to represent enums | |
| More on that here: https://stackoverflow.com/a/15713789/361842 | |
| This is the beginning of a reusable base class to allow me to easily create | |
| these pseudo-enums without having to repeat myself each time. | |
| Not yet complete; once done I'll add another file to this gist to represent a couple of use cases... | |
| */ | |
| public abstract class AdvancedEnum |
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
| //case of the format makes no difference (e.g. D and d give the same output / have no impact on the output string's case as suspected) | |
| Guid guid = Guid.NewGuid(); | |
| Console.WriteLine(guid); //same as D/d | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("D")); //digits and hyphens | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("d")); //digits and hyphens | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("N")); //just digits | |
| //75dad47898cf4a5fafc4ad172747db0b |