PowerShell for IT Professionals [#17] – Scripting part 4 – parameters, running remotely and formatting

In the last part of scripting series, we will make the script to be able to query remote machines, e.g. servers. We will also check how to add parameters to the script (and configure the default value of parameter) so that user will able to pass the parameter name like in a standard PowerShell cmdlet. Finally, we are going to format the script so that it looks more reliable and make some refactoring so that the logic is simpler....

19 October 2020 · 2 min · 425 words · Kamil

PowerShell for IT Professionals [#10] – Remote management with PowerShell

In this lesson we’re going to learn how to do one-to-one and one-to-many remote management with PowerShell. There’s no need for telnet, ssh or psexec as PowerShell has its own protocol that’s built in right into Windows. We will look at how to create interactive sessions and send commands to multiple servers at once. Exercises Notes Enable-Psremoting Enter-PSSesion ps-svr1 Hostname Get-Service GIP # I can even run commands that are not available on my source machine Get-ADDomainController Get-ADUser Exit or Exit-PSSession # Caution about double hoping Invoke-Command Invoke-Command -computerName ps-svr1 -command { get-service} # Invoke command executes commands on the remote comptuers and brings back the results # Can you tell a difference?...

24 August 2020 · 1 min · 176 words · Kamil

PowerShell for IT Professionals [#3] – Running Commands

Exercises Display a list of all services that start with the letter W Display all processes (you might need to use Help to discover the right command. Remember the noun might be singular). Open Notepad (you can simply punch in notepad in the shell) Display only processes that have a name “Notepad” Once you can there’s only one instance of Notepad running, close it with PowerShell! (Verb would be Stop) Confirm with Shell there are no more Notepad processes running Display last 10 lines of C:\windows\setupact....

27 July 2020 · 2 min · 257 words · Kamil