- 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 989 Articles for Software & Coding
![kannan sudhakaran](https://www.tutorialspoint.com/articles/images/user_icon.png)
656 Views
The default configuration should be modified when you use Git for the first time. The git config command can be used to achieve the same. The following are some Git configuration settings that can be set −NameEmailDefault EditorLine EndingsGit allows us to configure the above settings at different levels. This means we can have different settings for different repositories of different projects. All configurations are stored in a configuration file.SyntaxThe syntax to modify Git’s configuration is −git config configuration_name [additional_flags]Git configuration can be modified at the following levels −System − System−level configuration is applied across an entire machine and ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
8K+ Views
Suppose we have a XML file as shown below. Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating applications with XML. We need to add a new node. So we will first load the XML file and then operate on it as shown below.The below command will save the XML file to the variable.$xmlfile = [XML](Get-Content C:\Temp\SampleXML.xml)The below command will create a new XML element$newelement = $xmlfile.CreateElement("book")Once the element is created we need ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
We need to remove the window service named TestService using PowerShell. If you are using PowerShell 6.0 or above version, you can directly use a cmdlet Remove-Service command as shown below.In this example, we have a service name called TestService.Remove-Service Testservice -Confirm:$false -VerboseIf you are using the PowerShell framework version (5.1 or below), you need to use the registry. Services are stored in the registry at the below location.HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\To delete the service, we need to remove that service key with the command as shown below.Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\TestService | Remove-Item -Force -Verbose Here we are using the Service name TestService and you need to reboot the server ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
To run Invoke-Command in PowerShell Workflow we need to use the InlineScript block because Invoke-Command is not supported directly in the workflow. The below example is without using the InlineScript block we get an error.ExampleWorkflow TestInvokeCommand{ Invoke-Command -ComputerName LabMachine2k16 -ScriptBlock{ Get-Service WINRM } }Output −At line:2 char:5 + Invoke-Command -ComputerName LabMachine2k16 -ScriptBlock{ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cannot call the 'Invoke-Command' command. Other commands from this module have been packaged as workflow activities, but this command was specifically excluded. This is likely because the command requires an interactive Windows PowerShell session, or has behavior not suited ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
PowerShell workflows are the best way to design the script to execute on more than one node parallel which saves extensive time for the output to produce but we always don’t want to run all the commands parallel but also need some of them to run sequentially and we can design both Parallel and Sequence commands using PowerShell Workflow.Workflow TestWorkflow{ parallel{ Command1 Command2 } Sequence{ Command3 Command4 } } TestWorkflowIn the above code, Command1, Command2 will be executed parallelly in any order while command3 ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
9K+ Views
There are two ways to use the foreach loop parallelly in PowerShell.Using Foreach-Object -Parallel command (Supports in PowerShell 7.0 or above)Using Foreach -Parallel in Workflow (Supports PowerShell 5.1 or below)Suppose we have Servers.txt and which contains 10 Servers. When we use the Parallel for loop, it isn’t guaranteed which server loop will pick first as shown below with two examples.Using Foreach-Object-Parallel command. (not Foreach -Parallel)This Foreach-Object -Parallel command feature is newly added to the PowerShell version 7.0 or above.Example$servers = Get-Content C:\Temp\Servers.txt $servers | foreach-Object -parallel{ Write-output "Working on $_" }OutputPS C:\> C:\Temp\Test1.ps1 Working on IndiaServer003 Working on IndiaServer002 Working on IndiaServer001 Working on ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
366 Views
PowerShell workflow is built on the .Net based Windows Workflow Foundation (WWF) and it has a separate Workflow engine to execute the code because it translates code into XAML for the WWF framework.PowerShell workflow is series of steps that is mainly used forRunning activities parallelly on more than one machine.Long-running scripts.Structuring steps (Which steps will execute parallel and which in sequence)Frequently used tasks.Resuming the script from where it was terminated due to system failure or any other interruption by defining checkpoints.The PowerShell workflow was introduced in PowerShell 3.0 and discontinued for windows in the Core version (6.0 onwards) and only ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
To validate the IP address using PowerShell, we can use several methods as shown below.Using RegEx method.Using Typecasting method.Using TypeCasting method.In this method, we are using System.Net method class IPAddress to validate the IP address.[ipaddress]$IP = "192.168.0.1"The above one is valid. Let’s check what $IP stores in.PS C:\> $IP Address : 16820416 AddressFamily : InterNetwork ScopeId : IsIPv6Multicast : False IsIPv6LinkLocal : False IsIPv6SiteLocal : False IsIPv6Teredo : False IsIPv4MappedToIPv6 : False IPAddressToString : 192.168.0.1The above one is Ipv4 and this method also works for IPv6. See the example below.PS C:\> [ipaddress]"2001:0db8:85a3:0000:0000:8a2e:0370:7334" Address : AddressFamily : InterNetworkV6 ScopeId ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
To check if the PowerShell string contains a specific word, we can use the string method Contains(). For example, ExamplePS C:\> $str = 'TestNZ01LT' PS C:\> $str.Contains('NZ') TrueNow the funny thing is, even if the PowerShell is case-Insensitive, the above command is not. We need to provide the exact substring. For example, the below output will be false.ExamplePS C:\> $str.Contains('Nz') FalseTo overcome this problem, we can either provide the same search name in the method or we need to use the lowercase or uppercase method if you don’t want the search case-sensitive.PS C:\> $str = 'TestNZ01LT' PS C:\> ($str.ToLower()).Contains(('Nz').ToLower()) True ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
To convert any command output to the hashtable in PowerShell, we can first convert the output to the JSON format using the ConvertTo-JSON command, and applying the ConvertFrom-JSON command from the first output will produce an output to the Hashtable.ExampleGet-ServiceThe above command will give the output in the array format.OutputStatus Name DisplayName ------ ---- ----------- Stopped WwanSvc WWAN AutoConfig Stopped XblAuthManager Xbox Live Auth Manager Stopped XblGameSave Xbox Live Game Save Stopped XboxGipSvc Xbox Accessory Management Service Stopped XboxNetApiSvc Xbox Live ... Read More