Skip to main content

Posts

Showing posts with the label powershell

How to become a better programmer

I'll be the first to admit, programming was never something I found easy. My very first experience in programming was when I got this book at the ripe age of 11. I liked playing my Nintendo 64  and wanted to make games on my own. The book that changed it all for me My ability was far under sub-par. Somewhere in these  forums I wrote a post asking for help trying to understand a while loop - needless to say I got defensive because I felt I was being talked down by people smarter than me, telling me that I should start and learn more simpler things first (than dive right into making a PC game). Forums did actually look like this (circa 2005) The truth was, I was being too ambitious. BUT - TwisterMan was not going to code itself! (All drawn in glorious Microsoft Paint :)). Animation frames of TwisterMan doing some whirlwind attack Watch out for spikeo ! *rawr* And whoever this boss was called... Baaaa? The point I'm trying to get across i...

Powershell notifications with Windows Forms

What do we get more than anything, notifications . I'm a fan of turning them off (when I can), but if you wanted to show notifications through Powershell, here's a way how to do that. A notification in Windows 10 Adding Windows Forms We are going to leverage the NotifyIcon class built into Windows Forms in order to display our notification in Powershell. This is possible through the Add-Type cmdlet available in Powershell. With the Add-Type cmdlet, we can add the Windows.Forms assembly directly into our Powershell instance and use types like we would in code. This can be done with the following code. Add-Type -AssemblyName System . Windows . Forms Once this assembly is loaded into memory, we can begin to set the properties of the NotifyIcon and display it from Powershell. Setting the properties Before we set the properties on our notification, we need to create a NotifyIcon first. This can be done with the New-Object cmdlet. $notification = New-Obje...

Deleting old files with Powershell

Practical Powershell. Today we will be using Powershell to help you with day-to-day tasks. We are going to explore how to create a Powershell script to delete old files on your hard drive. Like I have said before , I enjoy Powershell and like how it gives me more control over my computer, particularly how it makes mundane tasks a lot more simple [and fast] for me to do. The good news is that if you don't have a lot of experience with Powershell, it is quite easy to extend and build new features using the language. Powershell (not the official logo) Let's get started. Writing the script In order for us to delete all of the old files from our hard drive, we need to be able to somehow find all these old files. A better question to ask would be; "what qualifies a file as old?" For the purposes of this example, let's assume that any file that has not been modified in the past 3 years be marked as "old" and should be deleted. Great - now how do w...

Logging into a website with Powershell

Powershell is great, and it's lately been my go-to shell while I'm working on Windows. Sorry command prompt I really don't do a lot of work in the shell, but I do like to play with low-level interfaces from time to time. The article is about Linux shells, but goes into good explanation about what a shell is if you don't know. Log into a website Today, I wanted to do something that I have never really tried before and that is logging into a website using Powershell . The concepts behind this are quite simple really, as Powershell has support to send HTTP requests  and that's usually all we need, unless the server has CSRF protections in place (which it should). We are going to attempt  to log in to my favorite website for buying socks, Absolute Socks : Is that a turkey?! In order to do that, we need to have a login. So if you don't already have an account on www.absolutesocks.com , go make one now. Viewing the login request On websites,...