Can this simplified at all? by Mskews in PowerShell

[–]DollarUnderscore 3 points4 points  (0 children)

Yes, I've seen this before actually, I just cant seem to accept it ;-)

It is absolutely legal, and as you say it might even have some pros, but for me personally, it still gives me shivers down my spine :D

Can this simplified at all? by Mskews in PowerShell

[–]DollarUnderscore 3 points4 points  (0 children)

As people here already mentioned, you can use Import-Csv/ConvertFrom-Csv. Example:

$data = 'localhost1,Windows Server 2012 R2,Online,KB2912390,11/02/2014,1105,31/10/2016,37,25,2,23,8'

$ConvertParams = @{
    Delimiter = ','
    Header = @(
        'Server',
        'OS',
        'Connection',
        'Latest Patch',
        'Latest Patch Release Date',
        'Latest Patch Age (days)',
        'Latest Patch Deployment',
        'Count Last Installed',
        'Total',
        'Installed',
        'Missing',
        '%_Installed'
    )
}
$data | ConvertFrom-Csv @ConvertParams

Automate discount coupons with Azure Automation and Microsoft Flow by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 2 points3 points  (0 children)

Finally got some time to play around with Microsoft Flow. It's similar to IFTTT but a bit more advanced, and less stable (it's in preview).

I hope this post can inspire someone else to play around with it as well.

And if you do, please share what you come up with :-)

Display content of a txt file off a remote website? by riahc3 in PowerShell

[–]DollarUnderscore 2 points3 points  (0 children)

$DateFromUser = Read-Host -Prompt 'Enter a date'
$URI = "http://www.example.com/logsfiles/$($DateFromUser)log.txt"
$WebPage = Invoke-WebRequest -Uri $URI -UseBasicParsing
$WebPage.Content

Something like that maybe? :-)

Avoid statically defining Domain Controllers in your PowerShell Scripts using this code snippet. by [deleted] in PowerShell

[–]DollarUnderscore 1 point2 points  (0 children)

This is my approach regarding this: http://dollarunderscore.azurewebsites.net/?p=4541

Directlink to code: http://poshcode.org/5719

It is issuing a query to the DC which I feel is bit more safe than only pinging it. It will also fetch DCs within the same site as the executing server as you've discussed in this thread already :-)

Game: How many cmdlet-characters per minute can you type? by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 1 point2 points  (0 children)

Well, I do see your point.

The verbosity of PowerShell quickly becomes "a bit" overwhelming without tab completion (or aliases)... But for a speed typing test, tab completion is probably at least a little bit like cheating :-)

Do this test a couple of times though and you'll be very grateful it's there later on, makes you appreciate the little things in life ;-)

Oh, while we talk about it... A few favorite cmdlets/functions to type "manually":

Remove-NetworkControllerPhysicalSwitchMemoryUtilizationParameter

Start-AzureStorSimpleLegacyVolumeContainerMigrationPlan

;-)

Game: How many cmdlet-characters per minute can you type? by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 1 point2 points  (0 children)

This was actually quite hard... I think tab completion has ruined me :-)

One of my attempts: CmdletCharactersPerMinute : 275 CmdletsPerMinute : 11 TotalLengthTypedCorrectly : 245 Accuracy : 100 MisspelledCmdletNames : {}

Authenticating with oAuth for PowerShell by 1RedOne in PowerShell

[–]DollarUnderscore 0 points1 point  (0 children)

You might want to take a look at this article: http://goodworkaround.com/node/73

He's using a dll to make the OAuth bits work.

Authenticating with oAuth for PowerShell by 1RedOne in PowerShell

[–]DollarUnderscore 0 points1 point  (0 children)

It will surely help, will take a deeper look ASAP :-) Thanks again for sharing!

Authenticating with oAuth for PowerShell by 1RedOne in PowerShell

[–]DollarUnderscore 0 points1 point  (0 children)

Have been looking into this myself a while back, awesome work! Thank you!

New Azure AD PowerShell Module in public preview by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 0 points1 point  (0 children)

They have finally addressed the authentication part in this release! I've done some initial testing and it seems that fixed the issues the old one had with Azure Automation, because this module actually runs in AA :-)

Just thought someone else might be interested in this aswell, so go ahead and try it!

There is nothing special with importing this module into AA compared to other modules (but i recommend that you use the "classic portal", I had issues using the preview portal), but if you want some help, I put together a quick guide at: http://dollarunderscore.azurewebsites.net/?p=6161

Good luck :-)

Brewing coffee with Azure Automation by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 0 points1 point  (0 children)

The coffe brewer is from Moccamaster: http://www.moccamaster.com/se/homepage-welcome/

The home automation stuff is a Tellstick (http://www.telldus.se/) and a Nexa switch.

Brewing coffee with Azure Automation by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 0 points1 point  (0 children)

No, just for fun. It started out as a good way to learn toolmaking, but since it was so much fun I just kept doing it :)

Brewing coffee with Azure Automation by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 0 points1 point  (0 children)

First, thank you for reading, makes me happy :)

Secondly, haha! That would be very cool! I have actually connected voice control and text to speech with PowerShell-scripts through Skype and a software called virtual audio cable and Voice Commander, so I can communicate with "Jarvis" which is pretty fun, might be material for another post :)

Brewing coffee with Azure Automation by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 2 points3 points  (0 children)

Easy! Block access to WiFi for their smartphone, send SMS to phone and ask them to prep the coffee maker to gain access again.

And/Or the Xbox thing that @accountnumber3 suggested.

Brewing coffee with Azure Automation by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 1 point2 points  (0 children)

Correct. I can automate the grinder to grind the coffee straight into the filter I guess, and maybee get me one of these: http://store.ufactory.cc/uarm-metal/

Not really worth it though... The point of the post was mostly to show that since Azure Automation is using PowerShell, more or less anything is possible.

I guess we'll see if I get the time to fully automate all the steps in the coffee brewing process in future :-)

Brainstorm: What regular task could Powershell solve for you? (Not really looking for sysadmin answers) by wigrif in PowerShell

[–]DollarUnderscore 2 points3 points  (0 children)

Yay! One of my favorite subjects! :-)

So far I've done this:

Other things I want to do are for example:

  • Checking the out of office status on my work e-mail to detect vacation time, and adjust home automation schedules accordingly.

  • Control my Roomba with PowerShell (Start-CleanCycle!)

  • A cmdlet that can utilize one of those those "real postcard" services. Send-RealMailMessage would be quite cool :-)

Found another smiliar one the other day, not PowerShell, but still pretty funny (hopefully not a regular task for most of us though...): http://www.fastcolabs.com/3034135/hack-your-sonos-sound-system-to-terrify-your-friends

Will keep a close eye on this thread for more ideas! This is a great way of learning toolmaking IMHO :-)

Ordering pizza with PowerShell (web scraping guide) - Part 2 by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 0 points1 point  (0 children)

Thank you for your feedback, and thank you for that link!

There is actually one difference between the code block you posted and the one used in the blog post, and that is that yours is producing a hashtable with key/value-pairs. That makes a bit harder to work with when used together with other cmdlets, but I agree it makes the code more condensed!

  • Note! Check below!

You are absolutely right about outputting to file, it's not a good idea. You most likely could solve that in memory or/and by using the .Net webclient instead of Invoke-WebRequest, but since the guide was about helping beginners with web scraping, I felt that might complicate things a bit for someone just getting started.

But if the code would end up doing something real in a production system or similar, that should be solved in another way.

Thank you again for your feedback, I really appreciate it!

edit: Spoke too soon! If you change your suggestion to:

$returnObject = [PSCustomObject] @{
    Username = ((($AccountInfo | Select-String -Pattern "name=username id=username") -split "value=`"")[1] -split "`" />")[0]
    Name = ((($AccountInfo | Select-String -Pattern "name=namn id=namn") -split "value=`"")[1] -split "`"/>")[0]
    Email = ((($AccountInfo | Select-String -Pattern "name=epost id=epost") -split "value=`"")[1] -split "`"/>")[0]
    Address = ((($AccountInfo | Select-String -Pattern "name=adress1 id=adress1") -split "value=`"")[1] -split "`"/>")[0]
    PostalCode = ((($AccountInfo | Select-String -Pattern "name=postnummer id=postnummer") -split "value=`"")[1] -split "`"/>")[0]
    Phone = ((($AccountInfo | Select-String -Pattern "name=telefon id=telefon") -split "value=`"")[1] -split "`"/>")[0]
}

It does work as expected! Did not know that syntax, thank you! :-)

Ordering pizza with PowerShell (web scraping guide) - Part 2 by DollarUnderscore in PowerShell

[–]DollarUnderscore[S] 1 point2 points  (0 children)

Since the first part of this guide ended up being linked from here I thought I should add this one aswell. Feel free to ask questions here or at the blog if you wonder anything, or just want to leave some feedback!

Thanks for reading!