Skip to content

Instantly share code, notes, and snippets.

@chustedde
Last active November 17, 2022 14:48
Show Gist options
  • Save chustedde/95e619c86a804258bd536bc5dd080cbb to your computer and use it in GitHub Desktop.
Save chustedde/95e619c86a804258bd536bc5dd080cbb to your computer and use it in GitHub Desktop.
Current profile - just a few useful aliases and functions for what I often do in PowerShell
Function Touch-File
{
$file = $args[0]
if($file -eq $null) {
throw "No filename supplied"
}
if(Test-Path $file)
{
(Get-ChildItem $file).LastWriteTime = Get-Date
}
else
{
echo $null > $file
}
}
Set-Alias touch Touch-File
Function Import-SPOModule
{
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
}
Function Connect-Exchange {
$O365Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
}
Function Sign-Script {
$file = $args[0]
if($file -eq $null) {
throw "No filename supplied"
}
else {
$cert = Get-ChildItem cert:\CurrentUser\My -codesign
Set-AuthenticodeSignature -FilePath $file -Certificate $cert[0]
}
}
@chustedde
Copy link
Author

Removed alias for Sublime since Sublime Text 4's subl.exe can be added directly to PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment