Tag Archives: loop

Internet-radio built in powershell

SRLast weekend I had an hour or two over after my kids gone to sleep, to do some scripting at home. I got an idea of building an internet radio in powershell with the four nationwide Swedish public service channels.  I used the .NET framework class System.Windows.Media.MediaPlayer to play the streams and then some variables to feed it. First of you could only choose channel when you ran the function and the only option was quit, but I built in a meny so you will be able to change channel without quiting the function. When I proudly showed the internet radio player to my girlfriend she told me it looked like crap and asked why I just don´t go to the sr.se site…

List and count users that never logged on to domain


I got an urgent case from the boss, we had to compare a list of users from our meta-catalog with users in our AD and list and count which users who never logged on to domain. I imported the csv in an variable and then used an foreach-loop to check if the users had logged in or not. We also wanted to list and count all users that where included in the csv-file but not in the active driectory, I used the ErrorVariable to do that and the appended each entry to a text-file with the out-file append switch. As you can see I used two different techniques to export multiple data from the foreach-loop. The first one when I exported the users that hadn´t logged on, where I first created an variable with an empty array  “$users = @()” , then instead of running the command to get the users I used the + to fill the array with result “$users +=”, on the second I used the out-file as I explained above.  When the lists where done I used the count and length property.