I am tracking notes on PowerShell in PS1 files on my git hub repository. You can see all 100 days of code entries on the blog category page.
As I write this I haven’t even finished chapter 13 yet and this already a really long post. Not sure if it’s just how it worked out or if 32 days in is my “past the hump” stage and this will be regular for the rest of the 100 days….
Having just finished taking notes on chapter 13 I think I will take a day to review all the stuff I’ve learned in these first 13 chapters. Although the first 3 are just about the help system so really 10. Whatever the chapter count ends up being I want to review the book tomorrow. And by coincidence the lab section for chapter 13 mentions questions covering more than just the one chapter. So it’s a good match. Also wish me luck.
As for the below it’s kind of a random assortment of thoughts probably not in chronological order. There is a correction related to some things I wrote about PS Remoting yesterday, so please do read.
I can’t believe I’ve been doing the same book for a whole month now. Looking back I think I really got started on chapter 5 around April 27th. So that’s 8 chapters in a month. I really shouldn’t be focusing on that part on that level. Those are just arbitrary numbers arbitrarily marking off sections of the book. I did want to be much further along than this by this point but I shouldn’t be hung up on the numbers themselves. The goal is to learn stuff after all not completing the book in and of itself.
As for today for some reason my PS remote session stopped working. I tried re-running the commands from yesterday and a few different things with the WinRM command but it didn’t seem to make a difference. Until it was mysteriously fixed. I don’t have any idea what if anything I did to make it start working. Which again is why I dislike WinRM in general: stuff randomly stops working that starts then break again for apparent reason.
Correction to the correction…
Below is all I wrote about what I thought I learned today about PS Remoting in a workgroup environment. But that I made a minor modification and I think I got around what I thought was the limitation: you can add multiple trusted hosts at once with a comma separated list. The part about the credentials is still true so far as I know.
The command I ended up using is:
winrm set winrm/config/client '@{TrustedHosts="ToughPeg,ThinkCentre1,GalacticaGamer7"}'
Instead of editing below I’m just going to leave it as is. This is how you learn after all. Keep trying things and taking notes about it. Also I’m lazy.
Correction on the thing I wrote yesterday e.g. 100 days of code: Day 31.
After a bunch of further experimentation today I’ve come to realize two thing about PSRemoting in a workgroup environment:
- Giving all the PCs the same user name and password makes authentication way easier
- PSRemote can only be used against one PC at a time
I’m at least as confident as I was yesterday I have figured this out: every time I would connect successfully to one of my network PCs a different one would stop working. Then I’d get that one working and a the first one would stop working.
So I’ve concluded it seems to only keep one PC in its “trustedhosts” setting at any given time.
On the other note, as mentioned yesterday a trusted network PC can be added with the line
winrm set winrm/config/client '@{TrustedHosts="ToughPeg"}'
but you also have to include -Credential <username> so it prompts for a password. For instance
Enter-PSSession -ComputerName toughpeg -Credential toughpeg\tildes
Will cause a logon box to pop-up asking for the password for toughpeg\tildes.
But if I used the same user name – tildes in this example – with the same password for all the PCs in the WORKGROUP I don’t have to specify that -Credential parameter, it will just take the credentials of the PC I’m remoting from. Or at least it works without specifying credentials so I’m just assuming that’s the thing that’s happening.
If the above is accurate or mostly accurate it means I can’t try that one-to-many invoke-command example in the book. At least not at home in my little workgroup. I setup a couple of different PCs on the LAN so I could try to run a command against three PCs at once. But it would appear this won’t be happening.
I should mention every time I wanted to connect to a different PC I had to re-run Enable-PSRemoting and that winrm set trusted host command against the PC I wanted to use.
If anybody knows of a way to add all those hosts let me know.
Separately, I also found out how to change arbitrary settings with that WinRM command though. This one changes the certification setting to false. There’s no reason to do this. I am just leaving it here as a reference in case a WinRM setting change is needed in the future:
winrm set winrm/config/client/auth '@{Certificate="false"}'
Also, I was thinking: as excited as I am to learn about WMI-via-PS in the book (is that sarcastic? I’m not sure) I think I want to take tomorrow – which I realize is Memorial Day – to really review this first half of the book and make sure I am actually learning and retaining helpful information. I’m on “24 hour standby” so I can’t really leave home anyway. So I’ll try to have some self control and review PS instead of playing games or watching TV all day. At least that’s the plan. I hope everyone else has a really great Memorial Day.