- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 463 Articles for PowerShell
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
287 Views
When we write a program, people from a non-programming background often expect to get much possible help related to the program. When we write the function and we declare the parameters, people who are unaware of what kind of input the parameter need, generally search for the help first using the Get-Help command and then they find only the parameters but not the description of it. For example, function TestFunct{ param( #16 Digit Application ID [parameter(Mandatory=$true)] [String]$AppID, #Date in the Unix Format - 2020-10-31T17:12:10+0530 [String]$Date ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
To disable the local user on the windows OS using PowerShell, we can use the Disable-Localuser command provided by the local user name. In the below example, we are going to disable the local user called TestUser.Disable-LocalUser -Name TestUserIf we see the GUI, the user account is disabled.To enable the above user, we can use the Enable-LocalUser command.Enable-LocalUser -Name TestuserTo run the above command on the remote computer, we can use the Invoke-Command method. We need to make sure local user account exist on the remote computer.Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock{ Enable-Localuser -Name TestUser }Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock{ ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
489 Views
To delete the local group from the windows system using PowerShell, you need to use the RemoveLocalGroup command as shown below.Remove-LocalGroup -Name TestGroupIn the above example, the local group name TestGroup will be removed from the local system. To remove the local group from the remote systems, we can use Invoke-Command as shown in the below example.Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock {Remove-LocalGroup -Name TestGroup}Remove-Localgroup command is supported from the PowerShell version 5.1 onwards and this command is a part of Microsoft.PowerShell.LocalAccounts module. If you have the PS version 5.1 or the local accounts module not available then you can use the ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
To remove a member from the local group using PowerShell, we can use the RemoveLocalGroupMember command. This command is available in the module Microsoft.PowerShell.LocalAccounts in and above PowerShell version 5.1.To use this command, we need to provide two parameter values. One is the -Group (Local Group Name) and the second is -Member (Name of the Member to remove). For example, Remove-LocalGroupMember -Group Administrators -Member TestUserThe above command will remove TestUser from the local group Administrators.To use the above command on the remote computer, we need to use Invoke-Command. For example, Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock{ Remove-LocalGroupMember -Group "Administrators" -Member ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
807 Views
To create a new local group on the local or the remote system using PowerShell, we can use the NewLocalGroup command. ExampleNew-LocalGroup -Name "TestGroup" -Description "Test Group"OutputName Description ---- ----------- TestGroup Test GroupYou can verify it from the Computer Management GUI.To create the local group on the remote systems, you can use Invoke-Command. For example, Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock{ New-LocalGroup -Name 'TestGroup' -Description 'New Test Group' }The above command will create a New Local group named ‘TestGroup’ on the remote systems, Test1-Win2k12, and Test1-Win2k16.New-LocalGroup command is available in the module Microsoft.PowerShell.LocalAccounts which is part ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
To add users to the local groups using PowerShell, we need to use the Add-LocalGroupMember command (Module − Microsoft.PowerShell.LocalAccounts).Add-LocalGroupMember -Group "Administrators" -Member "NewLocalUser", "labdomain\Alpha", "Labdomain\ITSecurity"The above command adds 2 users (NewLocalUser (Local) and Alpha (Domain)) and one Domain Security Group ITSecurity to the Local Administrators group.You can also use the other local group name instead of Administrators.To add the new users in the local group on the remote system(s) use the Invoke-Command method. For example, Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16{ Add-LocalGroupMember -Group "Administrators" -Member "NewLocalUser", "labdomain\Alpha", "Labdomain\ITSecurity" }Please note − To run the above command, the remote server must use ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
12K+ Views
To get the local groups on the windows system using PowerShell, you can use the Get-LocalGroup (Module: Microsoft.PowerShell.LocalAccounts) command. This command will list down all the groups on the particular system.If we check the properties of this command, it supports Name, Description, ObjectClass (user or group), PrincipalSource (ComputerName – Local or Remote), SID (Security Identifier).We will select them, PS C:\> Get-LocalGroup | Select Name, Objectclass, Principalsource, sid Name ObjectClass PrincipalSource SID ---- ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
41K+ Views
To get the local Administrators group members using PowerShell, you need to use the GetLocalGroupMember command. This command is available in PowerShell version 5.1 onwards and the module for it is Microsoft.PowerShell.LocalAccounts. This module is not available in the 32-bit PowerShell version but on a 64-bit system.In the below example, we need to retrieve the Local Administrators group members, ExampleGet-LocalGroupMember -Group "Administrators"OutputObjectClass Name PrincipalSource ----------- ---- --------------- User LABDOMAIN\delta Group LABDOMAIN\Domain Admins User TEST1-WIN2K12\Administrator User ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
102 Views
In part-1 we have seen the PowerShell pipeline functionality using the ValueFromPipeline property. There is another cmdlet property known as ValueFromPipelineByPropertyName, which is also useful to know the PowerShell pipeline functionality.Like part-1 command, we can get this property name using the same Get-Command but the filter parameter we will use for the property is ValueFromPipelineByPropertyName.The below example is for the Stop-Service cmdlet.(Get-Command Stop-Service).ParameterSets.parameters | where{$_.ValueFromPipelineByPropertyName -eq 'True'} | Select Name, ParameterTypeOutputName ParameterType ---- ------------- Name System.String[]This means you can use Name property to stop the service. So here we will use Get-Service and its Name property to retrieve services and ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
118 Views
PowerShell is made easier with the Pipeline structure. With the Pipeline structure, we can pass the input of the left side command output or string to the right side of the command as the input. For example, Get-Service | Out-File c:\services.txtIn the above example, we are passing Get-Service output as an object to the Out-File command which is the right side of the Pipeline as the Input. Before going into detail about how the Pipeline works, we need to understand that every command we write produces output and that output is already formatted by the PowerShell using Pipeline.For example, Get-Process ... Read More