<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://www.stugr.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.stugr.com/" rel="alternate" type="text/html" /><updated>2025-04-14T08:08:16+00:00</updated><id>https://www.stugr.com/feed.xml</id><title type="html">Nick Sturgess</title><subtitle>A collection of technology ideas by Nick Sturgess of Melbourne, Australia</subtitle><entry><title type="html">HEIC/HEVC support in Windows 10</title><link href="https://www.stugr.com/heic-hevc-support-in-windows-10" rel="alternate" type="text/html" title="HEIC/HEVC support in Windows 10" /><published>2021-06-12T00:00:00+00:00</published><updated>2021-06-12T00:00:00+00:00</updated><id>https://www.stugr.com/heic-hevc-support-in-windows-10</id><content type="html" xml:base="https://www.stugr.com/heic-hevc-support-in-windows-10"><![CDATA[<p>(While it is ridiculous that you need to do this,) to add HEIC/HEVC support to Windows 10 Photos app, either:</p>

<p>Open a browser and paste:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
</code></pre></div></div>

<p>Open a cmd window and paste:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>start ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
</code></pre></div></div>

<p>Then click install.</p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[(While it is ridiculous that you need to do this,) to add HEIC/HEVC support to Windows 10 Photos app, either:]]></summary></entry><entry><title type="html">Power Bi - Get users who have access to app (not workspace)</title><link href="https://www.stugr.com/powerbi-get-users-who-have-access-to-app-not-workspace" rel="alternate" type="text/html" title="Power Bi - Get users who have access to app (not workspace)" /><published>2020-12-16T00:00:00+00:00</published><updated>2020-12-16T00:00:00+00:00</updated><id>https://www.stugr.com/powerbi-get-users-who-have-access-to-app-not-workspace</id><content type="html" xml:base="https://www.stugr.com/powerbi-get-users-who-have-access-to-app-not-workspace"><![CDATA[<p>Power Bi doesn’t give you a way to get a list of users who you have granted access to an app. This is different to the list of users who have access to a workspace, which you <em>can</em> get using the API.</p>

<p>Go to Power Bi and choose to update app, then go to the the permissions tab and you can see that the list just shows names, and you cannot export.</p>

<p><img src="/assets/posts/powerbi-app/app-permissions.png" alt="app-permissions" /></p>

<p>Open Chrome F12 dev tools, and inspect a users name and you can see that there is a title attribute that contains the User Principal Name which we are interested in.</p>

<p><img src="/assets/posts/powerbi-app/f12.png" alt="f12" /></p>

<p>In the console at the bottom, paste this command to return a semi-colon delimited list of UPNs:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$$("span[class=displayName]").forEach(user =&gt; { console.log(user.title + ";") })
</code></pre></div></div>

<p><img src="/assets/posts/powerbi-app/console.png" alt="console" /></p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[Power Bi doesn’t give you a way to get a list of users who you have granted access to an app. This is different to the list of users who have access to a workspace, which you can get using the API.]]></summary></entry><entry><title type="html">Making Birthday Videos</title><link href="https://www.stugr.com/making-birthday-videos" rel="alternate" type="text/html" title="Making Birthday Videos" /><published>2020-10-16T00:00:00+00:00</published><updated>2020-10-16T00:00:00+00:00</updated><id>https://www.stugr.com/making-birthday-videos</id><content type="html" xml:base="https://www.stugr.com/making-birthday-videos"><![CDATA[<p>Covid and Melbourne lockdown have meant that most birthdays since March have either been run over Zoom or involved people pre-recording birthday messages for their friends.</p>

<p>I’ve been responsible for compiling a few together so thought I would finally document my steps. It might not be optimal but it’s what has worked for me.</p>

<ul>
  <li>Windows 10 Photos app - video compilation and basic trimming - you’ll need to at least be on the Windows 10 Fall Creators update from October 2017 - <a href="https://www.windowscentral.com/how-start-using-photos-video-editor-windows-10">basic guide on editing here</a></li>
  <li><a href="https://shotcut.org/download/">Shotcut</a> - boosting audio and any other fancy video things like un-stretching aspect ratios</li>
  <li><a href="https://www.audacityteam.org/download/">Audacity</a> - noise reduction</li>
</ul>

<p>You’ll likely be getting videos from all over the place in different formats. I received the majority through Messenger (.mp4), so for consistency, if a video was sent to me another way I would just send it to myself on Messenger to get an mp4 and deal with the slight compression. On your computer, go to <a href="https://www.messenger.com/">messenger.com</a> in a browser, click the video, then click download in the top right.</p>

<p>Will update this post later with more specifics on how to use each app</p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[Covid and Melbourne lockdown have meant that most birthdays since March have either been run over Zoom or involved people pre-recording birthday messages for their friends.]]></summary></entry><entry><title type="html">Becoming me - 2020 edition</title><link href="https://www.stugr.com/becoming-me-2020-edition" rel="alternate" type="text/html" title="Becoming me - 2020 edition" /><published>2020-08-08T00:00:00+00:00</published><updated>2020-08-08T00:00:00+00:00</updated><id>https://www.stugr.com/becoming-me-2020-edition</id><content type="html" xml:base="https://www.stugr.com/becoming-me-2020-edition"><![CDATA[<p>On learning to be kind to myself</p>

<blockquote>
  <p>What progress, you ask, have I made? I have begun to be a friend to myself</p>

  <p>— Senaca quoting Hecato</p>
</blockquote>

<h2 id="preamble">Preamble</h2>

<p><em>Written in August 2020 during Melbourne’s Lockdown 2.0 and only published in 2021 during Lockdown 3.0 :man_facepalming: whoops - will require a re-write / update / 2021 edition</em></p>

<p>You can jump straight to the <a href="#changes">changes</a> if you want.</p>

<p>I haven’t figured out if I will share this yet. Or how. Or if it’s even interesting. But I think I probably will because there is a chance that something in the below will help someone.</p>

<p>As you may know, I quit my job in October 2019 as I was burnt out after ~17 years (through acquisition) of being with the same company and industry - advertising, media and creative agencies. The final year of my constantly changing role was particularly challenging as the company went through multiple restructures, redundancies and budget cuts. When I resigned I had about 9 months of unused annual and long-service leave that was paid out, so the aim was to take 4-12 months off, recharge, spend more time with friends and family, climbing, hiking, camping, then once I felt ready, look for some more meaningful work (what does meaningful mean? yeah, more on that later)</p>

<p><img src="/assets/posts/becoming-me-2020-edition/work.jpg" alt="work" />
<em>We demand to be taken seriously</em></p>

<p>The first few months of not working were glorious. Within 2 weeks of my last day of work I finally sat my drivers license exam and got my manual license at the ripe old age of 36.</p>

<p><img src="/assets/posts/becoming-me-2020-edition/license.jpg" alt="license" />
<em>Thank you Jess for being an excellent and patient teacher</em></p>

<p>I learnt to trad climb at Dyurrite/Mt Arapiles with Jon, another excellent and patient teacher. I started doing more sport and trad climbing with Phil, Gerardo and Sean, completing my first few multipitches. My outdoor bouldering grade improved, completing a bunch of v4 climbs on days spent at Mt Alex, Benloch and Camels Hump with Phil, Tee or Bo. I booked to do the Kokoda trail in May with my little brother Lachie, and hiked whenever I could in preparation - Feathertop with snow a highlight.</p>

<p><img src="/assets/posts/becoming-me-2020-edition/arapiles.jpg" alt="arapiles" />
<em>Jon at Dyurrite/Arapiles on my first visit</em></p>

<p>I did 10 sessions with a psychologist while I had free access through works EAP (Employee Assistance Program). I had wrapped up a lot of my identity in my work, and with not working for the first time ever in my adult life I had quite a bit to do to figure out who I am, what I value, and what is my purpose - or at least I thought this was what I needed to figure out. I’d graduated school at 17, went straight to uni, then started my career at the end of my 2nd year of uni, going back to uni part time a year later to finish the course while still working.</p>

<p>People would ask me how I was going, and if I was thinking about looking for work soon. Around February/March I started to feel like I was ready to look for a couple of days of work a week.</p>

<p>Then covid hit.</p>

<h2 id="changes">Changes</h2>

<p>Firstly, some caveats. I know I’m lucky in that I don’t have dependents (a cat doesn’t count). I know people will scoff at my get up time ¯\_(ツ)_/¯</p>

<blockquote>
  <p>Surviving was enough for the first lockdown.<br />
If you pretend lockdown life is forever, ‘what does thriving look like?’</p>

  <p>— errr, me</p>
</blockquote>

<p>Back in March, Jess and I talked about writing down some predictions for ourselves for 3 months time (maybe with the view to it being post-covid? I don’t remember). I’d forgotten I’d written them down in OneNote and not shared them with anybody until now. I’ll come back to how accurate they were.</p>

<p><img src="/assets/posts/becoming-me-2020-edition/predictions.png" alt="predictions" class="border margin" /></p>

<p>In chatting with Jon at the start of April he had also asked me something similar. In some ways, everything I’ve written down here is answering him.</p>

<p><img src="/assets/posts/becoming-me-2020-edition/jon.png" alt="jon" class="margin" /></p>

<p>I found this video about Spaceship You helpful, particularly the bit about the core generator being your health made up of two halves (physical and mental) and if the core is low, it’s easier to start with the physical half.</p>

<div class="youtube-wrapper">
    <iframe src="https://www.youtube.com/embed/snAhsXyO3Ck" frameborder="0" allowfullscreen=""></iframe>
</div>

<h3 id="routinestructure---taking-sleep-more-seriously">Routine/Structure - Taking Sleep More Seriously</h3>

<p>Without work to provide a defacto structure, I recognised that if I didn’t invent my own I would slip into old habits of going to bed late, which means I would get up late, I’d then eat lunch quite late, leading to eating dinner late, going to bed late, and so the cycle would repeat.</p>

<p>I also have accepted that I’m a night owl, and therefore more likely to be productive later in the day, so I don’t try and force myself to work first thing in the morning. A few years ago I saw Dan Pink’s opening keynote at Telstra Vantage talking about <a href="https://www.cnbc.com/2018/04/30/daniel-pink-how-to-time-your-day-for-peak-performance.html">knowing your chronotype</a></p>

<p>My basic structure looks like this - I’ve listed the night time first, because without nailing the night, I won’t nail the morning</p>

<ul>
  <li>night
    <ul>
      <li>no active brain activities like gaming after 11pm (now 10:30pm for solo gaming)</li>
      <li>play with my cat Arya (generally while watching half an ep of <a href="https://en.wikipedia.org/wiki/Taskmaster_(TV_series)">Taskmaster</a></li>
      <li>hop into bed to read</li>
      <li>in bed ready to sleep by 12am</li>
      <li>alarm set for 9am every morning</li>
    </ul>
  </li>
  <li>morning
    <ul>
      <li>be out of bed within 20 minutes of alarm going off</li>
      <li>chuck on exercise clothes and either run or do yoga before showering or eating anything</li>
    </ul>
  </li>
  <li>day
    <ul>
      <li>I ‘work’ a normal day - tick off things on my various to do lists</li>
      <li>lunch at a regular time around 2pm</li>
    </ul>
  </li>
  <li>evening
    <ul>
      <li>stop working around 6pm-7pm and cook dinner at a regular time</li>
    </ul>
  </li>
</ul>

<p>I think I might add in a wind down activity like doing a jigsaw at some point.</p>

<h3 id="better-habits---identity">Better Habits - Identity</h3>

<blockquote>
  <p>Every action is a vote for the type of person you wish to become</p>

  <p>— James Clear - Atomic Habits</p>
</blockquote>

<p>Here a few more little excerpts from the book <a href="https://www.goodreads.com/book/show/40121378-atomic-habits">Atomic Habits</a>. I actually listened to the audiobook while running/walking/riding and then purchased the paperback. It had always been on my list of books to read, but thanks Karloskar for inspiring me to actually do it.</p>
<ul>
  <li>The most effective way to change your habits is to focus not on what you want to achieve, but on who you wish to become</li>
  <li>Your identity emerges out of your habits.</li>
  <li>The real reason habits matter is not because they can get you better results (although they can do that), but because they can change your beliefs about yourself</li>
</ul>

<h4 id="re-become-someone-who-reads">Re-become someone who reads</h4>

<p>I had actually started trying to read more this year already with the rough goal of reading 12 books (1 a month), but the reading of Atomic Habits helped me frame why and how. I also realised that reading non-fiction before bed wasn’t the best way to form a reading habit, so I’ve switched to reading some fantasy genre trash as John calls it</p>

<p>What I’ve read so far this year:</p>

<ul>
  <li><a href="https://www.goodreads.com/book/show/56627.Stumbling_on_Happiness">Stumbling on Happiness - Dan Gilbert</a></li>
  <li><a href="https://www.goodreads.com/book/show/17349.The_Demon_Haunted_World">The Demon-Haunted World: Science as a Candle in the Dark - Carl Sagan</a></li>
  <li><a href="https://www.goodreads.com/book/show/96799.The_Beckoning_Silence">The Beckoning Silence - Joe Simpson</a></li>
  <li><a href="https://www.goodreads.com/book/show/40121378-atomic-habits">Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones - James Clear</a></li>
  <li><a href="https://www.goodreads.com/book/show/18600.Touching_the_Void">Touching the Void - Joe Simpson</a></li>
  <li><a href="https://www.goodreads.com/book/show/23419.The_Consolations_of_Philosophy">The Consolations of Philosophy - Alain de Botton</a></li>
  <li><a href="https://www.goodreads.com/book/show/29093292-the-daily-stoic">The Daily Stoic: 366 Meditations on Wisdom, Perseverance, and the Art of Living - Ryan Holiday &amp; Stephen Hanselman</a></li>
  <li><a href="https://www.goodreads.com/book/show/1319.The_War_of_Art">The War of Art: Break Through the Blocks &amp; Win Your Inner Creative Battles</a></li>
  <li><a href="https://www.goodreads.com/book/show/19161852-the-fifth-season">The Fifth Season - N.K. Jemisin</a></li>
  <li><a href="https://www.goodreads.com/book/show/26228034-the-obelisk-gate">The Obelisk Gate - N.K. Jemisin</a></li>
  <li><a href="https://www.goodreads.com/book/show/31817749-the-stone-sky">The Stone Sky - N.K. Jemisin</a></li>
</ul>

<h4 id="continue-being-a-physically-active-person">Continue being a physically active person</h4>

<p>Metro Melbourne in stage 4 lockdown meant we can/could only leave our houses once a day to exercise for 1 hour.</p>

<p>To maximise this exercise time outside I decided to add learning yoga using <a href="https://www.downdogapp.com/">Down Dog</a></p>

<p>Each day I would either:</p>

<ul>
  <li>go for an hour long walk in the middle of the day when hopefully the sun was shining and chat with friends on the phone while I did so</li>
  <li>get up in the morning and run 3km in docklands and then do yoga on the boardwalk or grass if the sun was out (otherwise I’d go home post run and do yoga inside)</li>
</ul>

<p>My daily activities have now evolved into doing a collection of the below:</p>

<ul>
  <li>run 2-5x a week</li>
  <li>yoga (vinyasa atm) 3-7x a week - now we have 2h of allowed time outside I am doing this on a nearby grass patch when the sun is out</li>
  <li>small group personal training for 1 hour over Zoom 3x a week with <a href="https://www.thebiomechanics.com.au/small-group-personal-training-iso-edition">The BioMechanics</a></li>
  <li>walk for an hour if the sun is out - thanks to all the friends who’ve answered their phones while I walk</li>
  <li>bicycle - it’s my only form of transport</li>
  <li>climb a bluestone wall :speak_no_evil:</li>
</ul>

<h4 id="habit-tracking">Habit tracking</h4>

<p>I’m using a habit tracking app on my phone that sends me a notification at 11pm each night to check-in about my day. There are plenty out there, and I just stuck with the first free one I tried, <a href="https://apps.apple.com/au/app/daylio-journal/id1194023242">Daylio</a></p>

<p><img src="/assets/posts/becoming-me-2020-edition/habits.png" alt="habits" /></p>

<p>Some highlights:</p>

<ul>
  <li>flossing! for the first time in my life I am flossing every night for over a month!</li>
  <li>playing with my cat Arya - making sure she gets some quality play time considering how much time we spend at home and has been a good way of ensuring she burns energy before I want to sleep</li>
  <li>no reading comments on the internet - much better for my mental health</li>
  <li>activate my glutes - they are lazy!</li>
  <li>tracking a general exercise streak - currently at 51 days in a row since starting to track (<em>2021 update - streak lasted for 134 days!</em>)</li>
</ul>

<h3 id="other-general-things">Other general things</h3>

<p>I’m making a lot more of an effort to actively seek out human contact through phone and video calls - normally I’d get this interaction in person.</p>

<p>Giving plasma every 2-4 weeks.</p>

<p>I had a few online sessions with a different psych for free as part of another work EAP. The psych got me to do something I’d wanted to do for ages but never got around to which was to actually define my values. They are still a work in progress but for now they are:</p>

<ul>
  <li>humour</li>
  <li>honesty</li>
  <li>trust</li>
  <li>autonomy</li>
  <li>mastery</li>
  <li>purpose</li>
  <li>tribe</li>
  <li>respect</li>
  <li>social responsibility</li>
  <li>understanding &amp; curiosity</li>
  <li>freedom &amp; flexibility</li>
  <li>enthusiasm</li>
  <li>lists ;)</li>
</ul>

<p>You may have noticed the reading on philosophy. I’d asked John if he had a recommendation on a basic grounding in a bunch of different philosophies and he recommended Alain de Botton’s book which covers:</p>

<ul>
  <li>Consolation for Unpopularity (Socrates)</li>
  <li>Consolation for Not Having Enough Money (Epicurus)</li>
  <li>Consolation for Frustration (Seneca)</li>
  <li>Consolation for Inadequacy (Montaigne)</li>
  <li>Consolation for a Broken Heart (Schopenhauer)</li>
  <li>Consolation for Difficulties (Nietzsche)</li>
</ul>

<p>I found Epicurus, Seneca and Montaigne the most interesting, and from there I’ve then started reading more about Stoicism in particular which has helped me a lot during these last few months.</p>

<p>I have generally healthier consumption, and am looking forward to getting my cholesterol re-checked once lockdown eases:</p>

<ul>
  <li>cut down on meat last 12 months</li>
  <li>using chickpeas a lot</li>
  <li>done zero research, just doing whatever feels right</li>
  <li>snacking now often consists of either air-popcorn or a carrot with homemade hummus</li>
  <li>don’t really drink beer anymore - not that I ever really did at home, but not visiting the pub or going to gigs means way less beer consumption</li>
  <li>red wine has gone up - mostly on weekends, most weeknights are booze free</li>
  <li>still drinking plenty of water - thanks sodastream and big glasses</li>
  <li>cook a lot more - way less buying burgers and chips out</li>
</ul>

<h4 id="re-visiting-my-3-month-predictions">Re-visiting my 3 month predictions</h4>

<p>Back to those 3 month predictions where I was fairly prescient</p>

<ul>
  <li>learnt Arduino but in <em>your face past Nick</em>, I totally nailed my blinds as <a href="/2020/08/07/automating-venetian-blinds-with-arduino.html">outlined in this blog post</a></li>
  <li>learnt new recipes, and supermarket shortages generally meant less experimentation with exotic ingredients</li>
  <li>learnt to hangboard and did it while watching climbing videos because it is <em>so boring</em> so I don’t do it much</li>
  <li>abs - I definitely have a stronger core, but no noticeable visible difference</li>
  <li>bang on track with the reading target</li>
  <li>sleep routine is WWWAAAAYYY better!</li>
  <li>haha, yep, totally attempted multiple ways of calendaring my time</li>
  <li>I have a CV (and have taken some work)</li>
</ul>

<h4 id="what-have-i-learned">What have I learned?</h4>

<p>It’s hard.</p>

<h4 id="what-the-hell-youre-still-reading-this">What the hell, you’re still reading this?!</h4>

<p>I started this post with a quote that I’m also going to end with</p>

<blockquote>
  <p>What progress, you ask, have I made? I have begun to be a friend to myself</p>

  <p>— Senaca quoting Hecato</p>
</blockquote>

<p>I am a work in progress, and that is a good thing</p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[On learning to be kind to myself]]></summary></entry><entry><title type="html">Automating venetian blinds with Arduino</title><link href="https://www.stugr.com/automating-venetian-blinds-with-arduino" rel="alternate" type="text/html" title="Automating venetian blinds with Arduino" /><published>2020-08-07T00:00:00+00:00</published><updated>2020-08-07T00:00:00+00:00</updated><id>https://www.stugr.com/automating-venetian-blinds-with-arduino</id><content type="html" xml:base="https://www.stugr.com/automating-venetian-blinds-with-arduino"><![CDATA[<h3 id="summary">Summary</h3>

<p>To obtain optimal light blockage from my apartments poorly designed micro venetian blinds, I have flipped the blinds around so the tilt rod and raise/lower strings are now on the window side and hard to use.</p>

<p>This results in the bedroom blinds being left closed most of the time, and as my kitchen gets sunlight through the bedroom door, it leads to a dreary disposition.</p>

<p>This sounded like a perfect opportunity to improve my working from home experience through the use of technology by adding a button driven mechanical process to open and close my blinds, and I’d get to play with Arduino and do some more programming.</p>

<p><a href="#code">Code</a><br />
<a href="#wiring-diagram">Wiring diagram</a><br />
<a href="#finished-product">Finished product</a><br />
<a href="#parts-required">Parts required</a><br />
<a href="#decisions-i-had-to-make">Decisions I had to make</a><br />
<a href="#features">Features</a><br />
<a href="#todo">Todo</a></p>

<div class="youtube-wrapper">
    <iframe src="https://www.youtube.com/embed/7HNcTJCMwQM" frameborder="0" allowfullscreen=""></iframe>
</div>

<h3 id="code">Code</h3>

<p>Code is on <a href="https://github.com/Stugr/blinds-automation">github here</a></p>

<p><a href="https://github.com/Stugr/blinds-automation" title="click to view code on github"><img src="/assets/posts/blinds/code.png" alt="code" /></a></p>

<h3 id="wiring-diagram">Wiring diagram</h3>

<p><img src="/assets/posts/blinds/schematic.png" alt="wiring diagram" title="wiring diagram" /></p>

<h3 id="finished-product">Finished product</h3>

<p>Breadboard with open and close buttons attached to the wall. Lego tower behind the blinds, with the stepper motor stuck to the top. Shaft coupler connecting to the tilt rot.</p>

<p><img src="/assets/posts/blinds/layout.jpg" alt="layout" title="layout" /></p>

<p>Random angry birds lego tower I had in the cupboard that was basically the correct height. One day I may replace it</p>

<p><img src="/assets/posts/blinds/layout2.jpg" alt="layout2" /></p>

<h3 id="parts-required">Parts required</h3>

<p>If you don’t have any equipment yet, a <a href="https://www.jaycar.com.au/duinotech-arduino-starter-kit/p/XC3902">$40 kit at jaycar</a> containing an UNO Arduino-Compatible board, breadboard, usb cable, jumper wires etc might be a good start and may be cheaper than buying some of the parts individually</p>

<ul>
  <li>Arduino Uno - <a href="https://au.rs-online.com/web/p/processor-microcontroller-development-kits/7697409/">$33 at rs-online</a></li>
  <li>USB A to B cable - <a href="https://www.officeworks.com.au/shop/officeworks/p/keji-2m-usb-type-a-to-type-b-cable-cou2pc02">$5 at officeworks</a> or <a href="https://au.rs-online.com/web/p/usb-cables/8158450">$6 at rs-online</a> or <a href="https://www.jaycar.com.au/usb-2-0-a-to-b-cable-1-8m/p/WC7700">$10 at jaycar</a> - you may have one lying around from an old printer</li>
  <li>Stepper motor and driver board - <a href="https://au.rs-online.com/web/p/motor-control-development-kits/1845109">$10 at rs-online</a></li>
  <li>Shaft coupler - <a href="https://www.jaycar.com.au/solid-shaft-couplers-female-type-i/p/YG2600">$12 at jaycar</a></li>
  <li>Basic electronics components:
    <ul>
      <li>Breadboard - <a href="https://www.jaycar.com.au/arduino-compatible-breadboard-with-400-tie-points/p/PB8820">$8 at jaycar</a></li>
      <li>Jumper wires:
        <ul>
          <li>Plug to plug - <a href="https://www.jaycar.com.au/150mm-plug-to-plug-jumper-leads-40-piece/p/WC6024">$6 at jaycar</a></li>
          <li>Plug to socket - <a href="https://www.jaycar.com.au/150mm-plug-to-socket-jumper-leads-40-pieces/p/WC6028">$6 at jaycar</a> - connects the driver board to the breadboard/arduino</li>
        </ul>
      </li>
      <li>2x Buttons - <a href="https://www.jaycar.com.au/1-4mm-spst-micro-tactile-switch/p/SP0601">95c each at jaycar</a></li>
    </ul>
  </li>
  <li>Something to house the motor at the right height. I used a bunch of Lego I had lying around and double sided mounting tape which I already had in my toolkit <a href="https://www.bunnings.com.au/scotch-2-5cm-x-1-5m-extreme-double-sided-mounting-tape_p3961938">$11 at bunnings</a></li>
</ul>

<h3 id="decisions-i-had-to-make">Decisions I had to make</h3>

<h4 id="tilt-or-raiselower">Tilt or raise/lower</h4>

<p>Turning the tilt mechanism using either a servo or a stepper motor seemed like the best approach as then I wouldn’t have to figure out how to interface with the raise and lower string which is the kind you have to pull on an angle.</p>

<p><img src="/assets/posts/blinds/controls.jpg" alt="controls" title="controls" /></p>

<h4 id="where-to-attach-to-the-tilt-mechanism">Where to attach to the tilt mechanism</h4>

<p>I took down the blinds and experimented with housing a motor in the top rail connected to the horizontal metal rod that is responsible for the tilt, but there’s not much room up there (at either end), and I decided that a modification that could be removed easily to return the blinds to manual control was preferred. This meant that I was going to have to attach a motor to the tilt rod that a human normally turns.</p>

<p><img src="/assets/posts/blinds/housing.jpg" alt="housing" title="housing" /></p>

<h4 id="servo-or-stepper-motor">Servo or stepper motor</h4>

<p>A stepper motor allowed me to program in a set number of rotations between open and closed.</p>

<h4 id="manual-controls-or-automated">Manual controls or automated</h4>

<p>Keep it simple to start with, and use buttons to open and close on-demand instead of trying to get fancy with automatic function based on time of day, light levels, or voice control</p>

<h3 id="features">Features</h3>

<ul>
  <li>2x buttons - open and close</li>
  <li>Open state is blinds horizontal, close state is blinds vertical</li>
  <li>Stepper does 6 full rotations (so tilt rod turns 6x) between open and closed state</li>
  <li>Pretty quiet! (it turns pretty slowly, ~30 seconds to change states)</li>
  <li>Stores open or closed state in EEPROM to resume operation after power outages<br />
  <em>NB. To limit the number of writes to the finite EEPROM I am only storing the 2 major states of open or closed. This mean that in the rare case that power is lost while the blind is somewhere between open and closed state then a manual turning of the rod to reset state would be required</em></li>
  <li>While blinds are turning, press either button to cancel current operation. Press the appropriate button to either continue or return to previous state.</li>
  <li>Using 5V from Arduino to power stepper directly as well - will change this at some point</li>
  <li>Using the Arduino builtin pullup resistors for the buttons to simplify the wiring</li>
</ul>

<h3 id="todo">Todo</h3>
<ul>
  <li>Play more with a light sensor - living in the city means there is a lot of light bleed from nearby buildings and so I didn’t collect enough samples to decide on a light threshold for automatic opening and closing</li>
  <li>Add a <a href="https://www.jaycar.com.au/arduino-compatible-real-time-clock-module/p/XC4450">Real-time clock (RTC) module</a> for automatic opening and closing based on time of day</li>
  <li>Wifi for voice control via Alexa/Google home - I maybe should have bought an <a href="https://www.jaycar.com.au/uno-with-wi-fi/p/XC4411">Uno with wifi</a> instead of needing to add an <a href="https://www.jaycar.com.au/wifi-mini-esp8266-main-board/p/XC3802">ESP8266 board</a></li>
  <li>Play with hardware instead of software button de-bouncing</li>
  <li>Find something other than matchsticks to pad out the shaft coupler</li>
</ul>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[Summary]]></summary></entry><entry><title type="html">Track sleep using an IP camera with infrared</title><link href="https://www.stugr.com/track-sleep-using-an-ip-camera-with-infrared" rel="alternate" type="text/html" title="Track sleep using an IP camera with infrared" /><published>2020-07-17T00:00:00+00:00</published><updated>2020-07-17T00:00:00+00:00</updated><id>https://www.stugr.com/track-sleep-using-an-ip-camera-with-infrared</id><content type="html" xml:base="https://www.stugr.com/track-sleep-using-an-ip-camera-with-infrared"><![CDATA[<p>I live alone with my cat, and often wake up on strange angles with her sleeping on the other side of my legs than she was when I went to sleep.</p>

<p>I’ve been wondering what the quality of my sleep is like, and how much sharing a bed with a cat (or my partner) affects it, so I borrowed an IP camera with infrared from a friend.</p>

<p>This camera is <em>old</em> and so can’t do motion detection or write footage to a remote location (only SD card).</p>

<p>Below is the process by which I am recording the footage via an RTSP stream, analysing it for motion, then speeding it up so that I can watch a 2 minute summary.</p>

<p>Some of my notes after a few nights:</p>

<ul>
  <li>My cat cleans herself <em>a lot</em></li>
  <li>My partner grinds her teeth in her sleep</li>
  <li>I might have <a href="http://sleepeducation.org/sleep-disorders-by-category/sleep-movement-disorders/periodic-limb-movements/overview-facts">PLMS</a></li>
  <li>I am going to try locking my cat out for a few nights to see the difference this makes</li>
  <li>Play with <code class="language-plaintext highlighter-rouge">dvr-scan -roi</code> to specify region of interest to just detect motion of just me (head or feet), or cat</li>
  <li>Haven’t done anything with audio yet</li>
  <li>Try graphing motion event timeline using timestamps outputted by <code class="language-plaintext highlighter-rouge">dvr-scan</code></li>
</ul>

<p>Example output (roughly cropped to just my cat, you don’t need to watch me sleep ya weirdo):</p>
<div class="youtube-wrapper">
    <iframe src="https://www.youtube.com/embed/ZCUUOapwfEI" frameborder="0" allowfullscreen=""></iframe>
</div>

<h1 id="prerequisites">Prerequisites</h1>

<p>You will need a copy of <a href="https://ffmpeg.org/">ffmpeg</a> and <a href="https://dvr-scan.readthedocs.io/">dvr-scan</a> (which you’ll also need Python for). I’m running this on Windows and have my utils in my <code class="language-plaintext highlighter-rouge">%path%</code></p>

<h1 id="before-you-go-to-sleep">Before you go to sleep</h1>

<ol>
  <li>Change working dir to a new folder for each night</li>
  <li>
    <p>Start capturing RTSP stream into 5 minute long video files split using clocktime (so 1:00-1:05 etc). Each file is labeled <code class="language-plaintext highlighter-rouge">capture-xxxxx.mp4</code> where xxxxx is an incrementing 5 digit number.</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ffmpeg -i rtsp://user:pass@ip:port/11 -c:v copy -c:a mp2 -ar 44100 -aq 0 -ac 2 -map 0 -f segment -segment_atclocktime 1 -segment_time 300 -segment_format mp4 "capture-%05d.mp4"
</code></pre></div>    </div>
  </li>
</ol>

<h1 id="the-next-morning">The next morning</h1>

<ol>
  <li>Manually delete videos at the start and end that aren’t relevant (like reading in bed, getting out of bed etc)</li>
  <li>
    <p>Generate a file called <code class="language-plaintext highlighter-rouge">scan.txt</code> that contains the command for the next step that includes all remaining videos as parameters</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> powershell "'dvr-scan', (((Get-ChildItem capture*.mp4).name) -join ' -i ') -join ' -i ' | Set-Content scan.txt"
</code></pre></div>    </div>
    <p>Example <code class="language-plaintext highlighter-rouge">scan.txt</code> content:</p>
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> dvr-scan -i capture-00009.mp4 -i capture-00010.mp4 -i capture-00011.mp4
</code></pre></div>    </div>
  </li>
  <li>Open <code class="language-plaintext highlighter-rouge">scan.txt</code> and copy the contents into your clipboard</li>
  <li>Run <code class="language-plaintext highlighter-rouge">dvr-scan</code> command using the contents of your clipboard.<br />
 This outputs one file per motion event, auto-naming all files using the filename of the first provided input file with <code class="language-plaintext highlighter-rouge">DSME_xxxx</code> appended on the end eg. <code class="language-plaintext highlighter-rouge">capture-00009.DSME_0000.avi</code>, <code class="language-plaintext highlighter-rouge">capture-00009.DSME_0001.avi</code> etc.<br />
 <em>NB. dvr-scan outputs .avi and my attempts at using -c to specify a different codec were unsuccessful</em></li>
  <li>Manually delete videos of motion at the start and end that aren’t relevant</li>
  <li>
    <p>Output the filenames of videos of motion in the format that ffmpeg wants into a file called <code class="language-plaintext highlighter-rouge">files.txt</code></p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> powershell "(Get-ChildItem *DSME* | ForEach-Object { 'file ''{0}''' -f $_.name }) | Set-Content files.txt"
</code></pre></div>    </div>
    <p>Example <code class="language-plaintext highlighter-rouge">files.txt</code> content:</p>
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> file 'capture-00009.DSME_0000.avi'
 file 'capture-00009.DSME_0001.avi'
 file 'capture-00009.DSME_0002.avi'
</code></pre></div>    </div>
  </li>
  <li>
    <p>Run <code class="language-plaintext highlighter-rouge">ffmpeg</code> to stitch the videos together at 20x speed (for 10x change <code class="language-plaintext highlighter-rouge">0.05</code> to <code class="language-plaintext highlighter-rouge">0.1</code>)</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ffmpeg -f concat -safe 0 -i files.txt -filter:v "setpts=0.05*PTS" output.avi
</code></pre></div>    </div>
  </li>
  <li>Watch <code class="language-plaintext highlighter-rouge">output.avi</code> to see how badly you sleep</li>
</ol>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[I live alone with my cat, and often wake up on strange angles with her sleeping on the other side of my legs than she was when I went to sleep.]]></summary></entry><entry><title type="html">Fix Xbox One controller stick drift</title><link href="https://www.stugr.com/fix-xbox-one-controller-stick-drift" rel="alternate" type="text/html" title="Fix Xbox One controller stick drift" /><published>2020-06-23T00:00:00+00:00</published><updated>2020-06-23T00:00:00+00:00</updated><id>https://www.stugr.com/fix-xbox-one-controller-stick-drift</id><content type="html" xml:base="https://www.stugr.com/fix-xbox-one-controller-stick-drift"><![CDATA[<p>I had an Xbox One Elite Controller exhibiting stick drift on the left thumbstick - that is, when it was centred in the neutral position, the controller would act like you were pushing slightly up, causing characters in games to walk forwards constantly.</p>

<p>You can troubleshoot this kind of behaviour using the Xbox Accessories application on either Windows 10 or the Xbox One itself.</p>

<p>You can see in the bottom right of the screenshot below that the thumbstick is not centered at rest:</p>

<p><img src="/assets/posts/xbox/stick-drift.jpg" alt="stick drift" /></p>

<p>The elite controller retails for AU$200 and was out of warranty so fixing it myself seemed like a worthwhile project. I did a bunch of research, and while most fixes suggested that you would need to replace the whole analog joystick housing which would involve soldering, I figured out that there were 2 small sensors, each responsible for the x and y axis, that could be replaced instead and may fix my issue.</p>

<p>I ordered replacement parts from <a href="https://www.aliexpress.com/item/32897474633.html">AliExpress</a> (but didn’t wait for them to arrive). The whole housing looks like this:</p>

<p><img src="/assets/posts/xbox/analog-joystick.jpg" alt="analog joystick" /></p>

<p>The sensor inside which is the bit we want can actually be found in 360/PS3 controllers too and looks like this (left one is the damaged sensor from the Xbox One Elite Controller and the right one was taken out of an old Xbox 360 controller):</p>

<p><img src="/assets/posts/xbox/sensor.jpg" alt="sensor" /></p>

<p>You’ll need T6 and T8 security torx screwdrivers to pull apart the controller. Note the <a href="https://en.wikipedia.org/wiki/Torx#Variants">security torx variant</a> of the screwdriver has a hole in the middle due to the screws having a post in the center of the head. (You can also snap off this post with a small flathead screwdriver to enable a normal torx to fit, and I also discovered if you have the correct width flathead screwdriver you can then also turn the screw using this)</p>

<p>I used this video for help with dissassembling and reassembling the elite controller:</p>
<div class="youtube-wrapper">
    <iframe src="https://www.youtube.com/embed/tLt7lPE6bXI" frameborder="0" allowfullscreen=""></iframe>
</div>

<p>I used this video (starting at 4:32) for the sensor replacement:</p>
<div class="youtube-wrapper">
    <iframe src="https://www.youtube.com/embed/MoqW3PukDK0?start=272" frameborder="0" allowfullscreen=""></iframe>
</div>

<p>Xbox 360 controller:</p>

<p><img src="/assets/posts/xbox/xbox-360.jpg" alt="xbox 360 controller" /></p>

<p>Xbox One controller:</p>

<p><img src="/assets/posts/xbox/xbox-one.jpg" alt="xbox one controller" /></p>

<p>Now my Elite controller is working perfectly again, at least for now!</p>

<p><em>Note: Upon reassembly, the elite controller has a ribbon cable that controls the paddles on the back. If you re-connect this upside down the paddles will still work but the top left will now be the bottom right and so on.</em></p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[I had an Xbox One Elite Controller exhibiting stick drift on the left thumbstick - that is, when it was centred in the neutral position, the controller would act like you were pushing slightly up, causing characters in games to walk forwards constantly.]]></summary></entry><entry><title type="html">Fixing Outlook.com birthday calendar</title><link href="https://www.stugr.com/fixing-outlook-com-birthday-calendar" rel="alternate" type="text/html" title="Fixing Outlook.com birthday calendar" /><published>2020-05-28T00:00:00+00:00</published><updated>2020-05-28T00:00:00+00:00</updated><id>https://www.stugr.com/fixing-outlook-com-birthday-calendar</id><content type="html" xml:base="https://www.stugr.com/fixing-outlook-com-birthday-calendar"><![CDATA[<h3 id="outlookbirthdaycalendarps1">OutlookBirthdayCalendar.ps1</h3>

<p>PowerShell code is on github here: <a href="https://github.com/stugr/public-misc/blob/master/OutlookBirthdayCalendar.ps1">https://github.com/stugr/public-misc/blob/master/OutlookBirthdayCalendar.ps1</a></p>

<p>Outlook.com has an automatic birthday calendar and I have found the creation of entries to be incredibly unreliable, particularly when changing birthdays on a contact in iOS (mail account is added to iOS to allow contact syncing in both directions, and Save Contacts is turned off in the Outlook iOS app)</p>

<p>Read about the birthday calendar: <a href="https://support.office.com/en-us/article/add-a-birthday-calendar-in-outlook-com-b8e636da-fda8-413f-940e-68396efa49a6">https://support.office.com/en-us/article/add-a-birthday-calendar-in-outlook-com-b8e636da-fda8-413f-940e-68396efa49a6</a></p>

<p>Script requires Outlook to be installed and the account you want to use to be setup. Untested with multiple accounts.</p>

<p>After running in default whatIf mode to ensure it’s operating against the correct account and you’re comfortable with what it will do, toggle <code class="language-plaintext highlighter-rouge">$whatIf = $true</code> to run it for real</p>

<ol>
  <li>Gets all contacts from desktop Outlook app (so you will need to setup your account there)</li>
  <li>Set their birthdays to the vCard “no birthday” date of <code class="language-plaintext highlighter-rouge">1/01/4501 12:00:00 AM</code></li>
  <li>Do a send and receive and then wait for a bit for Outlook.com’s backend to catch up</li>
  <li>Set their birthdays back to the original values (which should prompt the backend to re-create the birthday calendar entry)</li>
  <li>Delete the additional automatic recurring event that desktop Outlook creates in the normal calendar (titled <code class="language-plaintext highlighter-rouge">$subject's Birthday</code>)</li>
</ol>

<p>Step 5 can be toggled off by setting <code class="language-plaintext highlighter-rouge">$deleteRecurringCalendarEntry = $false</code></p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[OutlookBirthdayCalendar.ps1]]></summary></entry><entry><title type="html">Get original Windows install date and upgrade history</title><link href="https://www.stugr.com/get-original-windows-install-date" rel="alternate" type="text/html" title="Get original Windows install date and upgrade history" /><published>2020-04-22T00:00:00+00:00</published><updated>2020-04-22T00:00:00+00:00</updated><id>https://www.stugr.com/get-original-windows-install-date</id><content type="html" xml:base="https://www.stugr.com/get-original-windows-install-date"><![CDATA[<p>If you use <code class="language-plaintext highlighter-rouge">systeminfo | find "Install Date"</code> you’ll find that it will only return the date of the last Windows 10 build that has been installed, instead of the original install date.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Original Install Date:     30/10/2019, 2:45:19 AM
</code></pre></div></div>

<p>Instead, you’ll need to hit up the registry.</p>

<p>Using powershell you are able to get the date for each upgrade build along with the very first install date.</p>

<p>Expanded longhand:</p>
<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># get old versions</span><span class="w">
</span><span class="p">(</span><span class="n">Get-ChildItem</span><span class="w"> </span><span class="nt">-Path</span><span class="w"> </span><span class="nx">HKLM:\System\Setup\Source</span><span class="o">*</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ForEach-Object</span><span class="w"> </span><span class="p">{</span><span class="n">Get-ItemProperty</span><span class="w"> </span><span class="nt">-Path</span><span class="w"> </span><span class="nx">Registry::</span><span class="bp">$_</span><span class="p">})</span><span class="w"> </span><span class="o">+</span><span class="w">
</span><span class="c"># append current version</span><span class="w">
</span><span class="p">(</span><span class="n">Get-ItemProperty</span><span class="w"> </span><span class="s1">'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w">
</span><span class="c"># select the fields we care about</span><span class="w">
</span><span class="n">Select-Object</span><span class="w"> </span><span class="nx">ProductName</span><span class="p">,</span><span class="w"> </span><span class="nx">ReleaseId</span><span class="p">,</span><span class="w"> </span><span class="nx">CurrentBuild</span><span class="p">,</span><span class="w"> 
</span><span class="c"># make date readable and convert from UTC</span><span class="w">
</span><span class="p">@{</span><span class="nx">n</span><span class="o">=</span><span class="s1">'InstallDate'</span><span class="p">;</span><span class="w"> </span><span class="nx">e</span><span class="o">=</span><span class="p">{([</span><span class="n">DateTime</span><span class="p">]</span><span class="s1">'1/1/1970'</span><span class="p">)</span><span class="o">.</span><span class="nf">AddSeconds</span><span class="p">(</span><span class="bp">$_</span><span class="o">.</span><span class="nf">InstallDate</span><span class="p">)</span><span class="o">.</span><span class="nf">ToLocalTime</span><span class="p">()}}</span><span class="w"> </span><span class="o">|</span><span class="w">
</span><span class="c"># sort</span><span class="w">
</span><span class="n">Sort-Object</span><span class="w"> </span><span class="s1">'InstallDate'</span><span class="w">
</span></code></pre></div></div>
<p>Collapsed shorthand:</p>
<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="n">gci</span><span class="w"> </span><span class="nx">HKLM:\System\Setup\Source</span><span class="o">*</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="p">{</span><span class="n">gp</span><span class="w"> </span><span class="nt">-Path</span><span class="w"> </span><span class="nx">Registry::</span><span class="bp">$_</span><span class="p">})</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="p">(</span><span class="n">gp</span><span class="w"> </span><span class="s1">'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">select</span><span class="w"> </span><span class="nx">ProductName</span><span class="p">,</span><span class="w"> </span><span class="nx">ReleaseId</span><span class="p">,</span><span class="w"> </span><span class="nx">CurrentBuild</span><span class="p">,</span><span class="w"> </span><span class="p">@{</span><span class="nx">n</span><span class="o">=</span><span class="s1">'InstallDate'</span><span class="p">;</span><span class="w"> </span><span class="nx">e</span><span class="o">=</span><span class="p">{([</span><span class="n">DateTime</span><span class="p">]</span><span class="s1">'1/1/1970'</span><span class="p">)</span><span class="o">.</span><span class="nf">AddSeconds</span><span class="p">(</span><span class="bp">$_</span><span class="o">.</span><span class="nf">InstallDate</span><span class="p">)</span><span class="o">.</span><span class="nf">ToLocalTime</span><span class="p">()}}</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">sort</span><span class="w"> </span><span class="s1">'InstallDate'</span><span class="w">
</span></code></pre></div></div>
<p>Example output from an old computer that’s been upgraded all the way since Windows 8.1:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ProductName     ReleaseId CurrentBuild InstallDate           
-----------     --------- ------------ -----------           
Windows 8.1 Pro           9600         16/09/2013 9:49:28 PM 
Windows 10 Pro            10240        1/08/2015 12:19:42 AM 
Windows 10 Pro  1511      10586        13/01/2016 3:47:41 AM 
Windows 10 Pro  1607      14393        9/10/2016 5:53:53 AM  
Windows 10 Pro  1703      15063        26/04/2017 10:50:15 PM
Windows 10 Pro  1709      16299        10/03/2018 1:32:55 PM 
Windows 10 Pro  1803      17134        17/05/2018 3:45:10 AM 
Windows 10 Pro  1903      18362        30/10/2019 3:45:19 AM 
</code></pre></div></div>

<p>NB. You may notice an hour discrepancy between the systeminfo and powershell outputs for the last install, likely due to daylight savings and how epoch time is stored by Windows and subsequently converted to current timezone. I’ve not needed this information to be absolutely precise so haven’t installed a fresh computer to see which one is the correct value.</p>]]></content><author><name>nickstugr</name></author><summary type="html"><![CDATA[If you use systeminfo | find "Install Date" you’ll find that it will only return the date of the last Windows 10 build that has been installed, instead of the original install date. Original Install Date: 30/10/2019, 2:45:19 AM]]></summary></entry><entry><title type="html">Where is an AD Account Lockout Occurring?</title><link href="https://www.stugr.com/where-is-an-ad-account-lockout-occurring" rel="alternate" type="text/html" title="Where is an AD Account Lockout Occurring?" /><published>2016-07-06T14:54:52+00:00</published><updated>2016-07-06T14:54:52+00:00</updated><id>https://www.stugr.com/where-is-an-ad-account-lockout-occurring</id><content type="html" xml:base="https://www.stugr.com/where-is-an-ad-account-lockout-occurring"><![CDATA[<p>How often do you hear “my account keeps getting locked out” followed by “I’m not typing my password wrong”?</p>

<p>I’ve found the easiest and quickest way to determine where the account lockout occurred is to query the PDC Emulator with Powershell. You may require a domain admin to do this.</p>

<pre class="brush: powershell; title: ; notranslate" title=""># Get PDC Emulator from the domain
$pdcEmulator = (Get-ADDomainController -Filter * | ? {$_.OperationMasterRoles -contains "PDCEmulator"}).hostname

# Run command against PDC Emulator
$lockouts = Invoke-Command -Credential (Get-Credential "DOMAIN\AdminAccount") -ComputerName $pdcEmulator -ScriptBlock
{
    # Filter on event id 4740 for the past 24 hours
    Get-WinEvent -FilterHashtable @{logname='security'; id=4740; StartTime=(Get-Date).AddHours(-24)} | select timecreated, @{N='who';E={$_.properties[0].value }}, @{N='where';E={$_.properties[1].value }}
}

# Search results for the user
$lockouts | ? {$_.who -eq "User.Locking" } | select timecreated, who, where | ft -auto</pre>

<pre class="brush: powershell; first-line: 13; title: ; notranslate" title="">TimeCreated             who               where            
-----------             ---               -----            
5/07/2016 1:34:12 PM    User.Locking      computerName
5/07/2016 12:34:12 PM   User.Locking      computerName
5/07/2016 10:46:47 AM   User.Locking      UAGserver
5/07/2016 10:01:56 AM   User.Locking      CASserver</pre>

<p>Depending on your environment, if you are seeing lockouts occurring on a workstation, it will generally be typing a password wrong or saved credentials somewhere. If you are seeing them at a UAG or CAS server, investigate their activesync devices.</p>

<pre class="brush: powershell; title: ; notranslate" title="">Get-ActiveSyncDevice -mailbox 'User.Locking' | ft guid, friendlyname, devicetype, whencreated -AutoSize</pre>

<pre class="brush: powershell; first-line: 2; title: ; notranslate" title="">Guid                     FriendlyName                 DeviceType    WhenCreated           
----                     ------------                 ----------    -----------           
28236d04-478a-433a-9af6  Outlook for iOS and Android  Outlook       15/06/2016 12:24:14 PM
4abe3b7c-cba3-45db-ade2  computerName                 WindowsMail   2/12/2015 4:19:10 PM</pre>

<p>If you need to remove these ActiveSync devices:</p>

<pre class="brush: powershell; title: ; notranslate" title="">$devices = Get-ActiveSyncDevice -mailbox 'User.Locking'

$devices | % { Remove-ActiveSyncDevice -Identity $_.identity }</pre>

<p>If you get an error like <code class="language-plaintext highlighter-rouge">An unexpected error has occurred and a Watson dump is being generated: Object reference not set to an instance</code> then set this before running remove:</p>

<pre class="brush: powershell; title: ; notranslate" title="">Set-ADServerSettings -ViewEntireForest $true</pre>]]></content><author><name>nickstugr</name></author><category term="Technology" /><category term="AD" /><category term="Admin" /><category term="Microsoft" /><category term="Powershell" /><summary type="html"><![CDATA[How often do you hear “my account keeps getting locked out” followed by “I’m not typing my password wrong”?]]></summary></entry></feed>