Skip to content

Instantly share code, notes, and snippets.

@manarth
Forked from rhysjtevans/SlackPost.ps1
Created June 10, 2019 14:16
Show Gist options
  • Save manarth/1e24cb6129bcf87018aecb472c0ecc77 to your computer and use it in GitHub Desktop.
Save manarth/1e24cb6129bcf87018aecb472c0ecc77 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