Tag: powershell

  • Powershell in a Month Day 15 – Jobs

    This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    Jobs are important, mostly because running stuff interactively, and manually, is a pain. The real power of PoSh administration, in my mind, is that not only can I run things across lots of servers, but I can also have some jobs run automatically. The Windows Scheduler isn’t always a part of this, though I’m not sure the PoSh system is better after reading this chapter.

    It’s a short one, but one that I did like. I’ve always liked scheduling jobs and having them do work for me. I can see this being handy, but the processing of results is something that will be important. That means saving this stuff off and practicing formatting.

    It’s an interesting approach here. The chapter has you create some jobs and then it explains how they work. Getting results, stopping jobs, checking them, etc. all occur as you have jobs running. All good admin things. I have the feeling I’ll refer back here as I build jobs.

    The scheduling comes after there’s an explanation of jobs themselves. We learn briefly how to schedule, but not in detail. To be fair, there isn’t a lot to worry about here.

    The lab was fairly easy. Most of the items were things I know how to do from the past, or I learned here. The recursing into subdirectories was a little tricky since I’ve used “/s” forever, but I needed to understand in PoSH that -recurse and -filter were needed here.

    I’ll be looking to play with some scheduled jobs that might clear out old files on my machine, especially backups. This would be some good practice for a job. I certainly should create a job to trim out IIS log files since that’s something I’ve seen needed on every web server I’ve encountered.

  • Powershell in a Month Day 14 – WMI

    This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    Day 14 introduces us to Windows Management Instrumentation (WMI). Since many people might not be familiar with WMI, the chapter spends a little time trying to help you understand what WMI is.

    I know what it is, I hate it, and I agree, it’s a PIA. It’s a mess, it’s inconsistent, and I’m not surprised the Powershell barely integrates with it. As with the cmdlets, this shows that there are the WMI cmdlets and the newer CIM cmdlets. The old ones like

    Get-WMIObject

    are somewhat deprecated. They work, but no development is being done. Instead, we need to use

    Get-CIMInstance

    That makes sense to me and I understand it. With no legacy work, I don’t think I have any issue with using Get-CIMInstance, though I do hate the idea of querying the WMI spaces. They’re a mess and nothing is intuitive.

    gwmi -class win32_bios -computer localhost,JollyGreenGiant | format-table @(l=’Host’;e={$_.__SERVER}

    There’s more to the table, but that’s all I typed in to test. I did a few more queries, with this and Get-CIMInstance to practice, but most of this chapter is really just understanding how WMI is organized to look for things and then formatting the results. Easy enough to do, a little boring, but good practice with expressions.

    The lab was annoying, mostly because it’s asking you to figure out which WMI classes to query. I googled around for some, and found them, but mostly this is annoying. I can certainly see where it’s handy to understand how WMI queries work, but like most people, I prefer to avoid them.

    Short chapter, easy, and good practice formatting things.

  • Starting to Use Powershell

    I have to admit that before the Powershell Challenge, I wasn’t really looking forward to using Powershell for much of anything. It looked cumbersome, I didn’t always understand how sample scripts worked, and it was just easier to use the various other Windows tools to accomplish tasks.

    However as I’ve been working through the Challenge, I’ve started to gain some comfort with the language, conventions, help, etc. This came into play recently as I was beginning to set up a new domain for some testing and demos.

    I installed Server Core and went to configure a domain, which means static IP addresses and more. Once I had Core installed, with no domain and no other tools, I was slightly stuck. However I googled and when I found things like

    Get-NetAdapter

    and

    Set-NetIPAddress

    I wasn’t at all deterred. I could easily read and understand the way these commands work, how parameters are applied, how precedence matters with parens and piping works. Even a restart was quick with

    Restart-computer

    or

    stop-computer

    When I needed to verify which machine I was actually working on

    $env:computername

    was a quick way that worked well.

    The whole world of Powershell starts to look easier as I go along. The slow movement through the book has made me more likely to run a quick search and type a command than use the GUI for a number of server-level tasks that I’ve needed to do.

    It’s a neat new world for me.

  • Powershell in a Month Day 13 – Remote Control

    This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    Remoting. It sounds complex, and intimidating. It isn’t, and it’s powerful. It’s also essential, allowing you to access commands on remove machines.

    The chapter starts with the idea of remoting, and running commands elsewhere. We learn this comes from telnet and other remote type access, and is implemented as a web services protocol, WS-MAN. Incidently, this is how SSMS works. Your T-SQL is executed remotely on the server, not on your workstation. Lots of people don’t get that and get confused.

    This chapter presents a challenge. You need a domain for security to work correctly, or easily, with remoting. There are potential workarounds, but it’s an issue. I haven’t had a domain at home because of overhead and not wanting a domain controller set up. That means some setup work to build a couple virtual machines and create a domain.

    Ugh. Annoying, but it’s something I should do. I have wanted to rebuild a domain for some time, but haven’t bothered, but this is the excuse to do so. As such, I read the chapter, and started setting up the domain. That will take a few days, so I’ll continue on with the next chapter as I get a domain ready. More notes to come once that’s done.