MitelNPUMTools.psm1
<#
.SYNOPSIS Uploads and activates voicemail greeting on individual mailboxes .DESCRIPTION The Set-NPUMMailboxGreeting cmdlet will upload all wav files in the C:\Greetings folder and request the mailbox number to activate it on. The Posh-SSH module must be installed. To do this on Powershell v4 and above run the following command install-module -Name Posh-SSH Greetings must be in the below format. CCITT u-law, 8KHz, 8 bit, mono. .PARAMETER ComputerName FQDN or IP Address of NPUM server to create connection .EXAMPLE Set-NPUMMailBoxGreeting 192.168.1.10 .NOTES A folder called Greetings needs to be created on the C Drive of your computer and the properly formated WAV files placed in here for upload. The upload procedure will also delete these files so make sure they are a copy and orginial placed somewhere for safe keeping. You will be prompted for the mailbox number for each file as it is being uploaded. .Link Posh-SSH #> Function Set-NPUMMailboxGreeting { [CmdletBinding()] Param( [Parameter(Mandatory=$True, HelpMessage="FQDN or IP Address of NPUM Server")] [Alias('Host', 'IPAddress')] [string]$ComputerName ) If (!(Get-Module -ListAvailable Posh-SS)) { Write-Output "You must install the Posh-SSH module before you can continue" Write-Output "1 Install Posh-SSH" Write-Output "2 Quit" do { $input = Read-Host "Please make a selection" switch ($input) { "1" {Install-Module -Name Posh-SSH -Force Import-Module -Name Posh-SSH} "2" {Exit} } } While ($True) } $FilePath = "C:\Greetings" $Credentials = Get-Credential root New-SFTPSession -ComputerName $ComputerName -Credential $Credentials New-SshSession -ComputerName $ComputerName -Credential $Credentials ForEach ($File in (Get-ChildItem -Path (Join-Path $FilePath -ChildPath *.wav))) { If ($File.Name.Contains(' ')) { Rename-Item -Path $File -NewName ($File.Name -replace ' ', '_') } $MailboxNumber = Read-Host "What mailbox number does $File need to be uploaded to?" $FullPath = Join-Path -Path $FilePath -ChildPath $File Set-SFTPFile -SessionId 0 -LocalFile $FullPath -RemotePath /tmp/VF $FileName = '"/tmp/VF/' + $File + '"' Invoke-SshCommand -SessionId 0 -Command "agreet_copy cmd=f m=$FileName m2=$MailboxNumber dg=1" Remove-Item $FullPath } Invoke-SSHCommand -SessionId 0 -Command "rm /tmp/vf*.wav" Remove-SFTPSession -Index 0 Remove-SshSession -Index 0 } <# <# .SYNOPSIS .DESCRIPTION .EXAMPLE .NOTES #> Function Set-BulkNPUMMailboxGreeting { ## Script to copy greetings over to mailboxes on a NuPoint server ## a csv file needs to be stored in C drive with 2 columns named Mailbox and File ## Mailbox is the mailbox number for the user and file is the file name of the new greeting. ## e.g. ## Mailbox | File ## --------|---------- ## 1460 | Scott.wav ## 1461 | Gary.wav ## ## Greetings must be in the below format and uploaded to /tmp on the MSL server. ## CCITT u-law, 8KHz, 8 bit, mono. $Server = Read-Host "Enter the IP Address or hostname of the MAS/NuPoint Server" $Username = "root" $Password = Read-Host "What is the password for $Username" New-SshSession -ComputerName $Server -Username $Username -Password $Password $a = Import-Csv c:\mbs.csv foreach ($item in $a){ $File = $item.File $Mailbox = $item.Mailbox $FileName = '"/tmp/VF/' + $File + '"' Invoke-SshCommand -ComputerName $Server -Command "agreet_copy cmd=f m=$FileName m2=$Mailbox dg=1" } Remove-SshSession -ComputerName $Server } #> |