Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Microsoft Technologies Articles - Page 182 of 204
427 Views
Although DSC is a very large topic, we will quickly summarize it in this article with the needed concepts to what exactly it is and how we can implement it.PowerShell Desired State Configuration (DSC) is an Infrastructure automation tool and used for Infrastructure as a Code (Iaac). Besides, DSC can also be used as an Inventory management tool like to get the specific inventory from the servers if they exist or not. PowerShell and DSC both are different things. However, DSC can be implemented using PowerShell.PowerShell script uses Imperative model means we need to write the script how we will ... Read More
3K+ Views
To convert the hashtable to the JSON format we can use the ConvertTo-Json command. First, we have the following hashtable,Example$Body = [PSCustomObject]@{ AppName = 'StorageXIO' AppID ='xo2ss-12233-2nn12' License = 'valid' }To convert the hashtable to the JSON format,$Body | ConvertTo-JsonOnce you run the above command, properties are converted to the JSON format.Output{ "AppName": "StorageXIO", "AppID": "xo2ss-12233-2nn12", "License": "valid" }
397 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
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
669 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
7K+ 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
1K+ 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
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
14K+ 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
52K+ 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