View PoshGram_Functions
#import the PoshGram module
Import-Module -Name "PoshGram"
#--------------------------------------------------------------------------
#easy way to validate your Bot token is functional
Test-BotToken -BotToken $botToken
#--------------------------------------------------------------------------
#send a basic Text Message
Send-TelegramTextMessage -BotToken $botToken -ChatID $chat -Message "Hello"
#--------------------------------------------------------------------------
#send a photo message from a local source
View get-filename
<#
.Synopsis
Returns file name from full file path
.DESCRIPTION
Takes a fully provided path to a file and returns just the file name of that path
.EXAMPLE
Get-FileName -FilePath C:\afolder\afile.txt
Returns just the filename from the fully provided path
.EXAMPLE
View ps_multipart_form
#Author: Jake Morrison - @jakemorrison - http://techthoughts.info/
#Contributor: Mark Kraus - @markekraus - from his post on PowerShell and Multipart/form-data - https://get-powershellblog.blogspot.com/2017/09/multipartform-data-support-for-invoke.html
#note: this was tested in PowerShell 6.0.2
try {
$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "chat_id"
$StringContent = [System.Net.Http.StringContent]::new("$ChatID")
$StringContent.Headers.ContentDisposition = $stringHeader
View Send-TelegramTextMessage
<#
.Synopsis
Sends Telegram text message via Bot API
.DESCRIPTION
Uses Telegram Bot API to send text message to specified Telegram chat. Several options can be specified to adjust message parameters.
.EXAMPLE
$bot = "#########:xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
$chat = "-#########"
Send-TelegramTextMessage -BotToken $bot -ChatID $chat -Message "Hello"
.EXAMPLE
View zip_module_dsc_azure
#used for zipping up custom dsc resources prior to upload to Azure automation
#--------------------------------------------------------------------------------
#install the required xPSDesiredStateConfiguration module if you haven't already:
#Install-Module xPSDesiredStateConfiguration
#--------------------------------------------------------------------------------
#import the module
Import-Module xPSDesiredStateConfiguration
#--------------------------------------------------------------------------------
#create the module .zip for Azure uploading
Publish-ModuleToPullServer -Name xNetworking -OutputFolderPath C:\DSC\Uploads `
View dsc_custom_config
Configuration Demo4 {
Param ()
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName xNetworking
node localhost {
#------------------------------------
WindowsFeature 'Telnet-Client' {
#DependsOn = "[WindowsFeature]Failover-Clustering"
Ensure = "Absent"
View Copy_RunLocal_withModule
#-------------------------------------------------------
#add a trusted source - only if required
#winrm s winrm/config/client '@{TrustedHosts="783721-hyp41,10.127.57.25"}'
#-------------------------------------------------------
#specify test device details and load up credentials
$s1 = "SERVER1"
$creds = Get-Credential -Message "Enter Credentials"
#-------------------------------------------------------
#create remote session with the appropriate options for your environment
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
View dsc_localhost
Configuration Demo3 {
Param ()
Import-DscResource -ModuleName PSDesiredStateConfiguration
node localhost {
#------------------------------------
WindowsFeature 'Telnet-Client' {
#DependsOn = "[WindowsFeature]Failover-Clustering"
Ensure = "Absent"
Name = "Telnet-Client"
View multi_node_dsc
Configuration Demo2 {
Param ()
Import-DscResource -ModuleName PSDesiredStateConfiguration
node $AllNodes.NodeName {
#------------------------------------
WindowsFeature 'Telnet-Client' {
#DependsOn = "[WindowsFeature]Failover-Clustering"
Ensure = "Absent"
Name = "Telnet-Client"
View dsc_push
#-------------------------------------------------------
#specify test device details and load up credentials
$s1 = "SERVER1"
$creds = Get-Credential -Message "Enter Credentials"
#-------------------------------------------------------
#create remote CIM session with the appropriate options for your environment
$sop = New-CimSessionOption –UseSSL -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$cim = New-CimSession -ComputerName $s1 -Credential $creds -SessionOption $sop
#-------------------------------------------------------
#push the configuration