UTF-8 vs ANSI – Errors with < : & and stacks of other characters

I just had an interesting experience trying to troubleshoot some problems with a PowerShell script that would work just fine when copied and pasted from Notepad++ into the PowerShell window, but would error out when run from the .PS1 file. It seems that nested variables would “get weird” when they were run from a UTF-8 file in PowerShell.

What was I doing with the code that was failing?

  • I was building out a HTML string in a variable and then using the string as the body of a HTML email which I was sending using the Graph API.

What tests had I run to try and eliminate large components?

  • The same HTML string worked fine when I sent it as an email using PowerShell’s Send-MailMessage (so, something to do with the way JSON was encoding the string maybe?),
  • The HTML string was emailed using the Graph API just fine when copied and pasted into the Powershell console (the same code works in the console but fails in the ps1 file),
  • The errors were all related to the mail function, and
  • I went through and tried to replace the “” by escaping a single set of double quotes with \”, then I replaced “” with ‘ to see if it made a difference

Could I narrow the scope down any more?

  • Remove the Function that sent the email, and the .ps1 script file ran fine
  • The HTML string being produced for the email body was valid HTML
  • The errors were being thrown at compile time, not during the execution of the script

Specifically I was getting these problems (in bold):

At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:484 char:267
+ ... n'>Exception! User account permanently added to Role and 
 is ...
+                                                                 ~
The '<' operator is reserved for future use.
 
At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:533 char:16
+             "isElevated": false,
+                         ~
Unexpected token ':' in expression or statement.
 
At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:555 char:43
+ ...    $EmailString = "Unexpected token 'bgcolor='#FFFFFF'' in expression or statement.
 
At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:556 char:117
+ ... br />Your friendly Office365 Platform Support Team
"
+                                                                         ~
The string is missing the terminator: ".
 
At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:412 char:9
+     try {
+         ~
Missing closing '}' in statement block or type definition.

At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:562 char:1
+
The Try statement is missing its Catch or Finally block.
 
At E:\OneDrive\PowerShell\SyncSelfElevationRightsWithADGroupMembership_AzureMailServer.ps1:363 char:33
+ function Send-NotificationEmail {
+                                 ~
Missing closing '}' in statement block or type definition.

None of these errors were valid! The syntax and bracketing etc. were fine (intellisense told me so, and it would have errored in the Powershell window when I ran it in there).

Finally, after much googling and swearing, I came across this Technet Forum discussion which mentioned the powershell file stopped working when it was saved in something other than ANSI… so I gave it a shot.

The first file executed in this screenshot is saved in UTF-8 file format. The second one is exactly the same file, but saved in ANSI format (even though it failed the AzureAD Module test, it compiled and ran without erroring).

image001

UTF-8 vs ANSI

My current working theory is the original file had some code copied from another Robocopy file (probably in UTF-8 format) which may have had an extended hyphen character or an unusual whitespace character in it. As soon as I saved it as AzureMailServer2.ps1 in ANSI format, it threw away all of the characters that were not ANSI compliant and worked just fine.

Just have to chalk that one up to experience I guess… 😊

Posted in Uncategorized | Leave a comment

Getting started managing SharePoint Online using Powershell

Whelp!
Started a new role today as an O365 Platform Specialist – It’s not entirely in my comfort zone, as I have no experience with Powershell (I’ve been a bit of an Ostrich until now, head deep in the sand) – but it’s time to take the plunge (particularly as all functionality is first released as Powershell Commandlets prior to the interface being built). I’m also extremely familiar with On-premises SharePoint, but differences in the online environment will be a relatively new experience.

I’ve always been of the belief that if you can explain something to your grandmother, then you have a good understanding of your topic. Unfortunately my grandmother’s passed away (I still miss her!) – so I’m using this platform to explain how to perform activities in SP Online using Powershell to all the grandmothers out there on the interwebs (well, at least the Grandmothers that are also SharePoint Online administrators!!).

I guarantee that if you have any experience in Powershell, you will roll your eyes so hard at my early entries that you’ll end up looking at the inside of your brain, but bear with me – we’ve all got to start somewhere! Happy to have any feedback, suggestions for online courses, etc – just comment below!

Posted in Uncategorized | Leave a comment

Stop it! Getting rid of that annoying Google alert!

If there’s one thing I hate, it’s being nagged. Particularly when the thing that’s nagging me is a machine, and it can do it infinitely… and especially when it’s nagging me about something I already do!

“Have you tried Chrome? It’s more secure!” Well, no… I use Edge… however I have installed and used Chrome.

“Why not set your home page to Google?” Uh… I have – but I still see you’re nagging me.

“Change your default search engine to Google” No need to, I see Google every time I open a tab!

As it turns out, it’s not hard, and it doesn’t require Adware plus or change the User Agent (which identifies the browser) to Google or a separate style sheet – but it’s buried in the Google settings – Here’s how to do it:

Open www.google.com and click the “bell” icon in the top right of the screen, then the cogs in the little fly-out window.

2017-11-26 18_58_39-Microsoft Edge

On the next screen, switch off notifications from Google (so the switch turns grey). Done!

2017-11-26 19_03_02-Microsoft Edge

Fair warning – this switches off all notifications – one of the options in the blue “Cogs” screen (below) is for the nagging alerts, but I don’t know which one – if someone works it out, let me know.

2017-11-26 19_09_22-Microsoft Edge

Enjoy!

Posted in Uncategorized | Leave a comment

Bulk “Unfollow” option in Twitter…

I just went hunting for a tool to quickly unfollow the 1200-odd accounts on Twitter that I never followed in the first place (most weren’t even in English). Turns out, it’s pretty easy…

Open the “Following” page on Twitter (https://twitter.com/following) and scroll down until all the accounts you are following are loaded in the browser. If you are following many accounts then you can place a heavy object on the Page Down button to scroll down automatically 🙂

Now open developer console (F12 in most Browsers) and paste the script below on the console run text field, then hit enter.

$(‘.button-text.unfollow-text’).trigger(‘click’);

It will look like your page has frozen, but it’s all good – just leave it running and it will eventually come back, with all of the accounts visible on the page now “Unfollowed”. Great jQuery script hack! Now I just need to figure out who is subscribing me to these random people…

Brad

Posted in Uncategorized | Leave a comment

Top things I like about the new Windows Phone 10

So I recently upgraded my phone from a Nokia Lumia 1020 (a phone I was very happy with) to the new Microsoft Lumia 950XL. All I can say is WOW… the phone is fantastic! So I thought I’d write up some of the features that I enjoy.

Let me begin by pointing out that I am a massive fan of a frictionless user experience. Phallic-based comparisons of “number of apps in store” don’t concern me as long as the apps I want are there, and the phone works the way I work…

  • Camera
    • Taking a photo is now an instant experience – photos are taken as quickly as you can click the button; there’s no “lag” either before or after taking the shot.
    • Each photo also captures a couple of seconds video before you click the button, and if you would prefer the shot from some other point in time captured in the video, you can! The feature is called “Living Image”; You’ll never miss the perfect shot!
    • Flash & Red-Eye – The flash is actually comprised of an RGB set of LED’s which helps prevent “red-eye” and “silver-eye”
  • Text Messages
    • You can now reply to texts without leaving your current application – clicking on the banner that appears with the text message in it lets you reply without switching to the messaging app then switching back
    • You can message via Skype or Text. It’s the same messaging app, and you see the messages in the same thread.
  • Reminders & Appointments
    • All my appointments and reminders are in the one calendar (Combining my 2 Exchange calendars, Outlook and Google)… but something I noticed last night – when you turn off the phone, instead of saying “Goodbye” it now says “Don’t Forget!” and gives you the details of your next appointment.
  • Maps
    • The one app (comes with the phone) now lets you mark where you parked your car, lets you work out how to get from point A to point B via car, walking or public transport (all over the world, online and offline), see various points of interest (and do things like find the nearest ATM, Thai Restaurant, Supermarket, etc.)
  • Reading View
    • Turning just about every content-based app sideways (so the phone is landscape aligned) switches on reading mode. The left side stays as emails, news articles, etc – the right side becomes the content itself. A much nicer experience and one I’m familiar with from Outlook (Reading pane)
  • Button positions
    • The buttons are always within easy reach of a person with normal hands while using the phone – nothing at the top, everything accessible by the hand that is holding the phone.
  • Continuum
    • OMG. I just used this at work, and it was fantastic. a-mazing. It turns your phone into a PC-like experience, and you can do it from the wireless Microsoft dongle too so with a couple of taps you are running a PC from the phone sitting by itself in the middle of the meeting room conference table! So sweet!
    • It’s a bit of a “Hammer looking for a Nail” but the tech is great, and it shows how people can be productive without having to have their PC with them.
  • Retina detection
    • Unlocking the phone is as simple as looking at it. It will even unlock if you are wearing sunglasses, because it uses an infra-red camera to detect the irises (and therefore works through the sunglasses which block visible and UV light, but not infra red).

There are lots of other nice little bonuses – those things that are tweaked from the previous iteration to make the entire user experience even better. As a person who’s highly mobile, I appreciate the blurring of the lines between devices and the workplace – and I’m looking forward to seeing what Microsoft do next in the mobile space. For those who are interested, Microsoft is not “exiting the phone market” – they’ve decided that it’s better to build a “best of breed” device and create interest around that (like what they did with the Surface Pro and Surface Book…).

 

 

Posted in Uncategorized | Leave a comment

Where Responsive Design Started…

I was just looking for a bit of information related to a proposal where the client asked for basic responsive design… and true to form, the internet delivered, giving me what I was looking for along with a ton of other info that was relevant, interesting (or both) – including the think piece that started the whole trend of “Responsive Design”!!!! That’s right, it hasn’t always been here, and it took a (damn fine) web designer to take a step back and look at the bigger picture… and come up with an approach that has now become synonymous with the “modern web experience”.

So… see where it all began! Go on, I know you want to… http://alistapart.com/article/responsive-web-design

Brad

Posted in Uncategorized | Leave a comment

OneDrive Troubleshooting Tip

Ever been frustrated with how OneDrive tells you “there’s a problem”, but doesn’t tell you what the problem is (and as such, gives you limited opportunities to fix it)?

End user tip: The file and folder icons of OneDrive have a little green blob in the bottom right corner when they are successfully synced. If they don’t, then that’s where your issue lies. Just follow the error icon down till you hit the file causing you problems, then open it in the native application to try and work out what the issue is.

For IT users: the Log Files are here: %localappdata%\microsoft\onedrive\logs

There’s a new sync client which works really well available here: https://support.office.com/en-us/article/Get-started-with-the-OneDrive-for-Business-Next-Generation-Sync-Client-in-Windows-615391c4-2bd3-4aae-a42a-858262e42a49 – Be aware there are a few limitations that may cause you to hold onto your legacy OneDrive for Business client. but some of the more problematic ones are now gone (such as maximum file count).

Posted in Uncategorized | Leave a comment

Issues with crashing Intel Video Drivers – Surface Pro 3

Over the past 2 months or so I’ve been dealing with a problematic video display driver issue which resulted in my display driver restarting (and the screen going black for 10 seconds or so while it reinitialised). At Empired Sydney, it would only happen once or twice a day, but at the Brisbane office it would happen every 10-15 minutes or so… Grrrr! I was getting errors with igfx (the Intel Graphics Drivers) and errors that SFC could not fix… so I stayed back last night to try and fix it. I tried uninstalling and reinstalling the drivers. I used a tool (here: http://www.majorgeeks.com/files/details/display_driver_uninstaller.html) to remove the drivers and then ran Windows update to have Microsoft reinstall them from the web. I tried running DISM to get the /SFC packages reset… no dice. Then I started looking at the monitor settings (the issue only occurs when I’m docked, and when the additional monitors are connected to the dock and not the Surface directly)… and saw that one of the external monitors was set to a refresh rate of 59.4Hz and one was set to 60Hz – Set them both to 60Hz and BAM! No more Graphics Driver failures.

At a guess it looks like the drivers are not stable when dealing with more than 2 refresh rates (The surface runs at 45Hz), AND the Surface is docked, AND the drivers are daisy-chained (DisplayPort v1.2). Change any of these parameters and the issues stop.

Sweet!

Posted in Uncategorized | Leave a comment

It’s Alive!!! SharePoint 2016 Developer Preview is now publically available!

Microsoft have released the Developer Preview for the latest version of SharePoint: SharePoint 2016! Being a developer preview, the interface (and potentially UI functionality) is not final, but the API is close to it (and it’s due out first quarter next year, so it’ll have some bugs in it too) – Full article is here: https://blogs.office.com/2015/08/24/announcing-availability-of-sharepoint-server-2016-it-preview-and-cloud-hybrid-search/

SharePoint Server 2016 further empowers your workforce by delivering a consistent experience across screens, whether using a browser on the desktop, a mobile device, tablet or slate. Through this rich experience, users can easily transition from one client to another without having to sacrifice feature fidelity.

Responsive by any other name smells just as sweet.

Q. Can I upgrade SharePoint Server 2016 IT Preview to RTM when released?

A. No, SharePoint Server 2016 IT Preview cannot be upgraded to RTM.

Fill yer boots!

Brad

Posted in Uncategorized | Leave a comment

What’s new in SharePoint 2016?

On the weekend I was lucky enough to give a presentation on all of the information out on SharePoint 2016 at the Office 365 Sydney Conference (#O365Syd), so I thought I would cover off a few of my favourite features below, and explain the value they are providing

#1 Durable Links

Finally, Microsoft have decided to finish the last 10% of the “Document ID” feature and make them the default (Only!!) links to documents. This is a feature that has existed in practically every Document Management system except SharePoint, and it removes so many of the issues surrounding document links: Limited URL length (255 characters), naming conventions (there should at least be parity with Windows folders, but have you ever tried to drag and drop a file in it with an ‘&’ in the filename?), file relocation breaking saved links, etc. I never understood why you got an “alternate URL” when you activated Doc ID’s. It never made any sense, and finally the full conversion over to durable links is done.

#2 Document Discussions

I always look at social media implementations in Enterprise businesses and ask “what is the problem it is trying to solve?”. Too often I get blank stares in return. Being able to discuss a document from the context of the document itself in a way that permanently captures the discussion (and with durable links, can always be linked back to the source document) solves 2 real-world problems. One being “How do we capture people’s feedback on documents in a way that others with feedback can get value from”, and the other, “How do we do it contextually from the document itself”. Both are real needs that all businesses face today and in 2016, the problems surrounding these needs are solved.

#3 Hybrid Search

Not really a SharePoint 2016-dependant feature, but due out at the same time as the beta is being released, so close enough

Microsoft have come up with a way of providing a unified search experience across all On-prem and cloud-based content storage environments (SharePoint, File Shares, web sites, CRM, SAP, the whole 9 yards). In the past, there’s been a separation with “on-premises” results and cloud results, and the best you could give the users was a federated view where the results came back in 2 separate result sets. An additional benefit is that you are “outsourcing” the crawling and indexing workload to the cloud, which (for larger implementations) means there’ll only be at most one standalone server providing search services. Previously, you might have had 4 or 5 sharing the crawling and indexing jobs, as well as responding to search queries.

There was heaps of other info that came out as part of Ignite, but these are probably my 3 favourites at this stage as they solve real problems with the way SharePoint works currently and aligns it more towards the way people want to work.

Compilation of Ignite information

Bill Baer’s IT Pro presentation

Posted in Uncategorized | Leave a comment