Skip to content

Instantly share code, notes, and snippets.

@rhysjtevans
Created June 10, 2019 13:32
Show Gist options
  • Save rhysjtevans/7a0d1bdf483651ebc7f054689ee1ea18 to your computer and use it in GitHub Desktop.
Save rhysjtevans/7a0d1bdf483651ebc7f054689ee1ea18 to your computer and use it in GitHub Desktop.
Install-Module -Name PSSlack -Force
Import-Module -Name PSSlack
$Workspaces = @{
LIVE = @(
@{
Uri = 'https://hooks.slack.com/services/XXXXX'
Workspace = 'YYYYY' # DSAB
Channel = 'ZZZZZ'
},
@{
Uri = 'https://hooks.slack.com/services/XXXXXX'
Workspace = 'YYYYY' # DSAB
Channel = 'ZZZZZ'
},
@{
Uri = 'https://hooks.slack.com/services/XXXXXX'
Workspace = 'YYYYY'
Channel = 'ZZZZZ'
}
)
TEST = @(
@{
Uri = 'https://hooks.slack.com/services/XXXXX'
Workspace = 'YYYY'
Channel = 'rhys.evans'
}
)
}
Function SlackIt {
$SenderPayload = @{
Username = "Rhys Evans"
IconUrl = 'https://dl2.macupdate.com/images/icons256/54025.png?d=1547052169'
}
$Payload = @{
Color = "Blue"
Pretext = @"
Hi folks,
Great tip if you work with Kubernetes and do a lot of ``kubectl edit``.
Found out today you can change the default code editor for kubectl and use VSCode instead.
Simply export a variable, then try editing a resource.
``export KUBE_EDITOR='code --wait'``
Obviously to persist this change, add it to your ``~/.bash_profile``
"@
# Title = "Settings.json Tip: Stop File Preview/Opening"
# TitleLink = ""
# ImageUrl = "https://miro.medium.com/max/977/1*8SYu5M6ouDaeVqJMk1_dDg.png"
# ThumbURL = "https://miro.medium.com/max/977/1*8SYu5M6ouDaeVqJMk1_dDg.png"
Fallback = "Great tip for kubectl edit"
}
$MSG = New-SlackMessageAttachment @Payload
Send-SlackMessage -Attachments $MSG @SenderPayload
}
foreach($Workspace in $Workspaces.LIVE){
Set-PSSlackConfig -Uri $Workspace.Uri
SlackIt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment