
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
Found 2039 Articles for Microsoft Technologies

3K+ Views
To remove the windows folder sharing using PowerShell, we can use the Remove-Smbshare command. For example, PS C:\Temp> Remove-SmbShare -Name DSC Confirm Are you sure you want to perform this action? Performing operation 'Remove-Share' on Target '*, DSC'. [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):Once you use this command, it will ask for confirmation. To remove the sharing forcefully, use - Force parameter. For example, Remove-SmbShare -Name DSC -ForceTo remove the shared folder permissions on the remote computer, you need to use the CIM session.In the below example, ... Read More

12K+ Views
To share a windows folder using PowerShell, we can use the New-SmbShare command. This command is a part of the module SmbShare.In this example, we have a folder called “DSC” and we want to share. The below command will simply share folderNew-SmbShare -Path E:\DSC\ -Name "Shared Folder"OutputName ScopeName Path Description ---- --------- ---- ----------- Shared Folder * E:\DSCDSC folder will be shared with a “Shared Folder” name with everyone’s Read Permission by default because we haven’t specified the scope yet.To assign the Full Access permission to the specific user, ... Read More

7K+ Views
To update the specific XML node using PowerShell, we first need to select that node with the attribute with SelectSingleNode() method.We have below the XML file from the link stored in SampleXml.XML on C:\Temp location.https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)In this example, we are going to update Autor and Genre properties of the Book having attribute Id = ‘bk102’$xml=[xml](Get-Content C:\Temp\SampleXML.xml)$node=$xml.SelectSingleNode("//book[@id='bk102']")The above commands will load the XML file and select node with attribute value ‘bk102’.$node.genre='Non-Fiction' $node.author='Dell James' $xml.Save("C:\Temp\SampleXML.xml")The above commands will update the genre and author property.Read More

11K+ Views
To delete the specific XML node from the PowerShell, we can use the RemoveChild() method of the XML.For example, We have a sample XML file from Microsoft.https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)We have saved the above file into C:\Temp\SampleXml.XML and we need to delete the book node with attribute ‘bk102’ and for that, we will use the XPath method of the XML.Below commands will first search the XML book node with the book attribute ‘bk102’ and then we will delete it.$xml = [xml](Get-Content C:\Temp\SampleXML.xml) $node = $xml.SelectSingleNode("//book[@id='bk102']") $node.ParentNode.RemoveChild($node) | Out-Null $xml.Save('C:\Temp\SampleXML.xml')If you want to delete all the nodes which have the name “Book”, we can ... Read More

8K+ Views
To add the attribute to the XML, we first need to add the Element and then we will add an attribute for it.Below is a sample of the XML file.Example Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating applications with XML. The below command will add the new element but the file won’t be saved. We will save the file after the attribute is added.$file = "C:\Temp\SampleXML.xml" $xmlfile = [xml](Get-Content $file) $newbookelement ... Read More

9K+ 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

6K+ 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

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

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

10K+ 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