Home » Posts tagged 'scripts'

Tag Archives: scripts

Give Your Skype for Business PowerShell Scripts a UI In 10 minutes

First off, this is not really a Skype for Business post, and I do not pretend to be a Dev, so if you are looking for in depth coding then there are others out there who are way better than me. However, I wanted to share with you a method that can be easily adopted to give your PowerShell scripts a nice User Interface.

Previously, designing a UI in PowerShell meant you had to either write hundreds of lines of code referencing the Windows.Forms library, drawing out objects, assigning styles to them etc. etc. Or buy expensive software such as Sapien’s PowerShell Studio that did most of the heavy lifting for you, but you needed to be somewhat of a PowerShell wizard to create even basic scripts. Neither solution for me was ideal, PowerShell Studio just made my head hurt, while going old school and writing line by line was inefficient and often a simple script would bloat out from 50-60 lines of code to easily 2 or 300 lines. This of course may be down to my n00b coding skills but I imagine there are many people out there like me.

Looking around, I found a few projects that had made PowerShell modules you could reference to build your UI, but still there was a dependency on that module being installed on the system the script would eventually run on. I stumbled on a forum post that suggested to use Visual Studio to build your UI and then import it into your PowerShell script.

I have never used Visual Studio before, mainly because I am scared of it and didn’t really know where to start. Plus I am an impatient man, so I just wanted to get things working as fast as I could. However, I was astonished how easy it was.

The process is really simple. Create your UI in Visual Studio using.. you guessed it, a UI to design your UI, drag and drop, select component etc. Once complete copy the code to your PowerShell script, convert into variables, then reference the variables in your code to “do stuff”.

(more…)

Skype for Business– Migrate-CsAnnouncements

Those of you familiar with Skype for Business voice functionality will be aware of the use of announcements. Announcements are pre-determined messages that can be played when a user dials an incorrect number, unallocated number and they can even be used to route into response groups and other third party applications.

These announcements are created and assigned to a particular application server pool i.e a front end pool. This assignment means that the application server is responsible for the announcement and the response group service of that application server is used in order to play the announcement to the caller.

When this application server pool is down, the announcement service will also fail. Pool pairing and automated failover scenarios out of the box do not handle the failover of announcements to the DR application pool. Therefore, in a pure failover scenario, the announcement service is not resilient.

Many customers can often have numerous announcements for whatever reason, and the normal process of migrating these is sadly to recreate them on another pool. Even migrating from previous versions of Lync, the announcements are not automatically migrated and there is no move-csannouncement PowerShell commandlet to help.

Announcing the new function Migrate-CsAnnouncements

(more…)

Auditing Installed Applications on Server or PC using Powershell

Here is a simple Powershell function to audit installed apps on local or remote machine using PowerShell. The script queries the registry for installed apps rather than using Get-WMIObject as this would rerun any msi installer packages and attempt a repair (an annoying side effect). The impact of the Get-WMIObject method would mean any custom changes to the MSI i.e manual service stop or desktop shortcut would be reversed. Using the registry is a lot safer and quicker. The account used to run this script must have local administrator access and the target machine should have remote management and remote registry enabled.

to run the script use the Get-InstalledSoftware commandlet without specifying anything this will audit the local machine. Specifying the -Computername parameter targets a remote machine. Reports are HTML reports that will be written to c:\Reports on the machine this script is executed from.

Script below

Function Get-InstalledSoftware(){ 
 Param (
 [string]$ComputerName)
 $a = "<style>"
 $a = $a + "BODY{background-color:peachpuff;}"
 $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
 $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
 $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
 $a = $a + "</style><title>Installed Applications</tif folditle>"
if (!(Test-Path -Path "C:\Reports")){
 $logFolder = New-Item -Path "C:\Reports" -ItemType Directory
}else{
 $logFolder = "C:\Reports"
 }
 if (!$ComputerName ){
 Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName} |`
 Select-Object DisplayName, Publisher, DisplayVersion, InstallDate | ConvertTo-Html -Head $a `
 -Body "<h1>Installed Applications</h1>" -As List | Out-File "$($logFolder)\installedapps.htm"
}else{
$query = Invoke-Command -ComputerName $ComputerName -ScriptBlock { Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |`
 Get-ItemProperty | Where-Object {$_.DisplayName} |`
 Select-Object DisplayName, Publisher, DisplayVersion, InstallDate}
 $query | ConvertTo-Html -Head $a `
 -Body "<h1>Installed Applications on: $ComputerName</h1>" -as List | Out-File "$($logFolder)\$($ComputerName)_installedapps.htm"
}
}

Skype for Business – Enabling Bulk Users

During a Lync 2013 install of over 2000 seats I had to enable bulk groups of users for Lync enterprise voice, PC to PC and Remote Call Control together with different pool assignments and policies. I created a script that would read from a user completed CSV file and enable users with the specified policies and pool associations.

The CSV file must have the following column headers and saved as LyncUsers.csv

ADUsername Pool LineUri SipAddress ClientPolicy ConferencePolicy DialPlanpolicy Voicepolicy ExternalAccessPolicy

The LineURI should be in format of tel:+441870123456;ext=987

The SipAddress should be in the format of sip:useralias@domain.com

If policies are not defined the default policies will be applied

For the script this is in a word document as this website does not allow .ps1 files to be uploaded. please copy the script contents to a notepad file and save with the .ps1 extension

lyncbulkusers_ps1

%d bloggers like this: