Posts

Showing posts from June, 2018

Stopwatches!

When playing with code to try and streamline the process I often add a stopwatch to the logging These are started: $stopwatch=[system.diagnostics.stopwatch]::startNew() Stopped: $stopwatch.Stop() (optional) Restarted: $stopwatch.Restart() Using these through the loggin process can highlight where loops can be improved on or commands take longer than usual (ie timeouts) Write-Output "Lab took $($stopwatch.elapsed.minutes)m:$($stopwatch.elapsed.seconds)s:$($stopwatch.elapsed.Milliseconds)ms to build" More on the stopwatch class https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.110).aspx

Update to Create-LabUsers - Enable for SfB

This is a further update to my previous postings ( )on changes I've made to Aarons script for creating lab users. One of my requirement was enable users for Skype for Business. This is reasonably straightforward. In order to connect remotely to the SfB powershell, we need credentials. Once connected, we can enable the users with a default sip address of their email account (so some checks need to be in place) Eagled eye readers will notice i've also included a stopwatch to monitor the execution times. Very useful when tweaking the scripts to streamline the proces. Top to bottom, the switches required are: #Skype4Business parameters [switch]$Skypeenable, [string]$SfBFEServer, [string]$SfBPool, SfBFEServer is the remote machine we will connect to to execute the commands. SfBPool is the pool where the users will be homed on. If not specified, the script will try to be smart and do a DNS lookup for the _sipinternaltls._tcp record The functions required are: Function...

Updating Create-LabUsers - take two

Over the past couple of days I've been tweaking and adding to this useful script. (Previous update here: https://jc-nts.blogspot.com/2018/06/tweaks-to-create-labusers.html Aarons blog posts can be found here: https://blogs.technet.microsoft.com/undocumentedfeatures/tag/create-labusers/ Several iterations later (and few thousand mailboxes): Added functionality to enable Skype for Business Split the user and mailbox creation Tweaked mailbox creation to include users not previously enabled Fixed an issue where the password complexity would error on user creation (that was fun!) Fixed an issue where email addresses contain invalid characters Shaved off a few seconds here and there Included some extra logging and timings It should reach around 1.1 million accounts per day if creating AD only, however the extra logging does add to the run times. Performance will be dependent on the specification of the DC being targeted. This way I can fire up a DC, create 5000 users and ...

Tweaks to Create-LabUsers

I mentioned in a previous blog post (setting up the homelab) that I used an excellent script from Aaron Guilmette to populate active directory ( https://blogs.technet.microsoft.com/undocumentedfeatures/tag/create-labusers/ ) There were a few tweaks that I made along the way, based on previous bulk user management trials and tribulations! A further update can be found here:   https://jc-nts.blogspot.com/2018/06/updating-create-labusers-take-two.html Skype for Business updates can be found here : http://jc-nts.blogspot.com/2018/06/update-to-create-labusers-enable-for-sfb.html Always connect to the same domain controller Creating a small number of accounts (with associated mailboxes, enabling for Lync/Skype for Business) in a large environment can produce unexpected problems, like not finding the account you have just created! In my experience, it turns out this was down to replication in AD. Two possible solutions are to build in delays to the script (not practical) or make s...

Homelab setup

Homelab - the toys! After a few years working with different companies and their various testing/training/development environments, I've always wanted a bit more control over the kit and longed to have my own 'proper' setup at home. So over the past few months i've built a new homelab. I wanted to have some storage and a UPS so decided I'd make space for a rack. After a few weeks/months of trawling ebay and other sites for various parts I've ended up with: 2 x DL380 G7s with 128GB ram and local storage 1x P2000 storage array with drives (shared cluster storage) 1x D2600 storage array with drives (I ordered the wrong drives for the P2000 and rather than return them, I found another enclosure) 3 x Cisco 2811 routers 2 x Cisco 3560 POE switches 1 x Cisco 3750G switch 1x APC220R and all manner of drives, cables, power strips, expansion cards and server memory. Not to mention a 36U rack to fit it all into. The end result is a small private cloud, wher...

Eh? Wait. How long...!

Absolutely amazed.... I'm absolutely amazed, and astonished, that so much time has passed and I've done little to update this blog/list. I have literally hundred of snippets, notes and scribbles from the field that should have made it this far, but for some reason, they haven't. If only to remind myself in another few years of how bad my notes are, prepare to be updated! Some absence is expected (I love to throw myself at new work and challenges) but almost 4 years has passed. Time for some updates! First up - the homelab.

Powershell snippets - Active Directory

Some AD powershell commands used at some point. Some are used more often than others. Exporting to CSV Exporting can be interesting with PS. For consistency, I stick the following on the end of any powershell I want to export. Add the current date onto the filename for potential comparison. export-csv -NoTypeInformation -Encoding Unicode -Path c:\temp\Domaincontrollers-$(get-date -f yyy-MM-dd).csv The only issue I sometimes encounter is copying to/from RDP session. The first copy can be corrupt - the second copy/paste is usually fine - this is likely to down to the current settings at a client. Get the current domain controllers and some OS information and export to CSV Get-ADDomainController -Filter * | Select-Object Hostname, Site, OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion, OperationMasterRoles, LdapPort, SslPort | export-csv -NoTypeInformation -Encoding Unicode -Path c:\temp\Domaincontrollers-$(get-date -f yyy-MM-dd).csv Get interesting AD...