• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/25

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

25 Cards in this Set

  • Front
  • Back

How can I use PowerShell to See If WinRM Is configured on a group of Remote Computers?

"s1","s2","dc1" | % { Test-WSMan $_ }

How can I test connectivity to remote servers to ensure my Windows PowerShell scripts will work if I have the PING blocked at the firewall?

Use Test-WsMan, for example:
's1','s2' | % {Test-Wsman $_}

What is the best way to test for an UP server before attempting a connect to it?

Test-Connection
The Test-Connection cmdlet sends Internet Control Message Protocol (ICMP) echo request packets ("pings") to one or more remote computers and returns the echo response replies.


How can you run Test-Connection, then if UP, do something?

if (Test-Connection -ComputerName www.google.com -Quiet){Write-Host "Found the site ok"} else {Write-host "Didn't find it"}

What purpose does the ForEach-Object serve?

The ForEach-Object cmdlet performs an operation on each item in a collection of input objects.
The input objects can be piped to the cmdlet or specified by using the InputObject parameter.

What are two ways that you can use ForEach-Object to get the value of the ProcessName property of each process on the computer?

Get-Process | ForEach-Object {$_.ProcessName}
Get-Process | ForEach-Object ProcessName

Using the Get-WindowsFeature cmdlet, display a list of server roles and features that are currently installed:

Import-Module ServerManager
Get-WindowsFeature *
Get-WindowsFeature * | Out-file c:\users\chris.orton\OSFeatures.txt

What end of the command should you do formatting?

Format Right - Format at the end of the commands.

What end of the command should you do filtering?

Filter Left - It is more efficient to filter returning data as close to the source of data as possible. e.g. filter the system event log on the server, and then return the data.

Although you can use 'NETDOM QUERY FSMO' to list domain controllers that hold the FSMO roles, how can you do it with Windows PowerShell?

Get-ADDomain | Select-Object InfrastructureMaster, RIDMaster, PDCEmulator
Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster


What does having a command in parentheses achieve? e.g. (Get-Service -Name gupdate).DisplayName

The parentheses will force PowerShell to first execute the command inside the parentheses, then do the item to the right.

The $_ symbol is a system variable that does what?

Points to the current object in the pipeline - followed by a period and the name of a property.

How can you chain two commands together on the same line?

Semicolon
e.g.
"s1","s2","dc1" | ForEach-Object $_ {$_ | Add-Content D:\Temp_Scripts\test.txt ; $PSVersionTable | Out-File D:\Temp_Scripts\test.txt -Append}

How do you continue a command over two lines?

back tick
`


How to display a list of CMDLETS?

get-command | more

With Add-Content, how do you add a new line to a text file

Add-Content c:\scripts\test.txt "`nThe End"
`n

How do you Add a timestamp to the end of bunch of .log files?

$A = Get-Date; Add-Content c:\scripts\*.log $A

What are the PowerShell versions installed in the OS by default?

Windows 7/Server 2008 R2 - PowerShell 2.0
Win 2012 / Win 8 - PowerShell 3.0
Win 2012 R2 / Win 8.1 - PowerShell 4.0
It needs to be installed on Win 2008, Vista, 2003, XP SP2.

What are some notable features that shipped in PowerShell 2.0?

PowerShell Remoting, Background Job, PowerShell Integrated Scripting Environment (ISE), Network File Transfer, Block Comments

What are some notable features / changes that shipped in PowerShell 3.0?

Scheduled jobs, Help update, Automatic module detection
New commands: Dozens of new modules were added, including functionality to manage disks, volumes, firewalls, network connections and printer management, previously performed via WMI

What are some notable features / changes that shipped in PowerShell 4.0?

Desired State Configuration
Enhanced debugging
New Default Execution Policy: On Windows Servers, the default execution Policy is now RemoteSigned

What are some notable features / changes that will probably ship in PowerShell 5.0?

Key features include OneGet PowerShell scriptlets to support Chocolatey's repository-based package management and extending support for switch management to layer 2 network switches

How can you show the operating system install date?

gwmi -query 'Select InstallDate from CIM_OperatingSystem' -computername localhost -namespace root\cimv2 | Select InstallDate

With PowerShell 2.0, how can you display a list of services that have a start type of Automatic, but that aren’t currently started?

# This works with PowerShell 2.0
Get-WMIObject Win32_service | Sort-Object Name | Where-Object {$_.StartMode -eq "Auto" -AND $_.State -eq "Stopped"}

With PowerShell 3.0, how can you display a list of services that have a start type of Automatic, but that aren’t currently started?

# This works with PowerShell 3.0
Get-CimInstance win32_service | Sort-Object Name | Select-Object Name,State,StartMode | Where-Object {$_.StartMode -eq "Auto" -AND $_.State -eq "Stopped"}