Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the practical cases of Windows PowerShell

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you what the Windows PowerShell practice cases are, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.

Task 1:

Can the following command get a list of Hotfix that has been installed on all computers in a particular domain? Explain the reason

Get-HotFix-ComputerName (Get-ADComputer-Filter * | Select-Object-ExpandProperty name)

Answer:

Get-Hotfix 's-ComputerName gets the pipe type: String [], and what is passed through () is the type and String. So the command can be run and the result is correct.

-ComputerName

Specify the remote computer. The default value is the local computer.

Type the NetBIOS name, Internet Protocol (IP) address, or fully qualified domain name of the remote computer.

This parameter does not depend on Windows PowerShell remoting. Even if your computer is not configured to run remote commands, you can use the ComputerName parameter of Get-Hotfix.

Is it necessary? False

Location? Named

Default value Local computer

Do you accept pipe input? True (ByPropertyName)

Do you accept wildcards? False

(Get-ADComputer-Filter * | Select-Object-ExpandProperty name) | gm

TypeName:System.String

Task 2:

Can the following command be taken from a list of Hotfix already installed on the same computer? Explain the reason

Get-ADComputer-Filter * | Get-HotFix

Answer:

The Get-Hotfix command supports ByPropertyName parameters, and the parameters passed by Get-ADComputer-Filter * are of type string. So the command can be executed. For more information, see the following:

Help Get-Hotfix-full view the following information

-ComputerName

Specify the remote computer. The default value is the local computer.

Type the NetBIOS name, Internet Protocol (IP) address, or fully qualified domain name of the remote computer.

This parameter does not depend on Windows PowerShell remoting. Even if your computer is not configured to run remote commands, you can use the ComputerName parameter of Get-Hotfix.

Is it necessary? False

Location? Named

Default value Local computer

Do you accept pipe input? True (ByPropertyName)

Do you accept wildcards? False

Get-ADComputer-Filter * | gm views the following information:

TypeName:Microsoft.ActiveDirectory.Management.ADComputer

Name MemberType Definition

-

Contains Method bool Contains (string propertyName)

Equals Method bool Equals (System.Object obj)

GetEnumerator Method System.Collections.IDictionaryEnumerator GetEnumerator ()

GetHashCode Method int GetHashCode ()

GetType Method type GetType ()

ToString Method string ToString ()

Item ParameterizedProperty Microsoft.ActiveDirectory.Management.ADPropertyValueCollection Item (string propertyName) {get;}

DistinguishedName Property System.String DistinguishedName {get;set;}

DNSHostName Property System.String DNSHostName {get;set;}

Enabled Property System.Boolean Enabled {get;set;}

Name Property System.String Name {get;}

ObjectClass Property System.String ObjectClass {get;set;}

Task 3:

Can the following command get a list of HotFix that has been installed on the computer in the domain? Explain the reason.

Get-ADComputer-Filter * | Select-Object @ {lumped computers ComputerNameters} = {$_ .Name}} | Get-HotFix

Answer:

The String type is passed through Get-ADComputer-Filter * | Select-Object @ {lumped ComputerNameters} = {$_ .Name}}, which exactly meets the name parameter receiving requirements of Get-FoxHit. Therefore, it can be executed correctly. The specific information is as follows:

Get-ADComputer-Filter * | Select-Object @ {lumped ComputerNameName} = {$_ .Name}} | gm to view the following information

TypeName:Selected.Microsoft.ActiveDirectory.Management.ADComputer

Name MemberType Definition

-

Equals Method bool Equals (System.Object obj)

GetHashCode Method int GetHashCode ()

GetType Method type GetType ()

ToString Method string ToString ()

ComputerName NoteProperty System.String ComputerName=WIN-JFDKC82CU4F

Task 4:

Use pipe parameter binding to write a command to get a list of running processes on each computer in the domain. Do not use parentheses.

Answer:

Get-ADComputer-Filter * | Select-Object @ {lumped computer names} = {$_ .name}} | Get-Process

Answer ideas:

Because Get-ADComputer-Filter * can only pass the Sting type of the ComputerName (ad computer name in the domain) of the name attribute, but the Get-Process can only receive the String type pipe of the ComputerName attribute, we convert the name to the String type pipe that can receive the ComputerName attribute by Select-Object @ {lumped computer name = {$_ .name}}.

Task 5:

You can use parentheses instead of the pipe input method to get a list of services that have been installed on each computer in the domain.

Answer:

Get-Service-ComputerName (Get-ADComputer-Filter * | Select-Object name-ExpandProperty name)

Task 6:

Confirm that the command is working properly and explain why.

Get-ADComputer-Filter * | Select-Object @ {lumped computers ComputerNameters = {$_ .name}} | Get-WmiObject-Class Win32_BIOS

Answer:

Cannot execute properly because the Get-WmiObject command does not support pipe input. The specific information is as follows:

Help Get-WmiObject-full can view the following information:

Input

None

Input cannot be passed to Get-WmiObject through pipes.

What are the above examples of Windows PowerShell practice? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report