- 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
Chirag Nagrekar has Published 465 Articles
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
500 Views
To add the new tag of Azure VM using PowerShell, we need to use the New-AZTag command. Please note: If you have already tags applied to the VM, you need to use the Update-AZTag command to merge with the available Azure Tags otherwise all the previous applied.For example, We have ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
22K+ Views
To run the PowerShell script from the command prompt, we can use the below command.ExampleFor example, we have a script TestPS.ps1 which first starts the spooler service and then copies a file to a different location. We need to call this script using the command prompt.C:\> PowerShell.exe -command "C:\temp\TestPS.ps1"The above ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
4K+ Views
If we want to delete the hidden files and folders from the C:\temp on the local computer, we need to use the command shown in this example.ExampleBut first, the below command helps us to retrieve the hidden files and folders from the C:\temp.Get-ChildItem C:\Temp -Hidden -RecurseWe just need to pipe ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
2K+ Views
To delete empty files and folders, we need to first retrieve the list and which has been shown in the earlier articles.ExampleIn this article, we are using the logic that if we find an empty file or folder we will delete them. To implement that logic, use the below script.gci ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
870 Views
The ConvertFrom-String command converts the String to the Hashtable format as shown below.ExamplePS C:\> "This is string" | ConvertFrom-StringOutputP1 P2 P3 -- -- -- This is stringIn the above example, We haven’t specified any header so that the output is separated the delimiter by space P1, P2 and continuous. By ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
3K+ Views
ExampleFor example, we have a below-created hashtable.PS C:\> $servicehash = @{Name='Spooler';State='Stopped';StartType='Automatic'} PS C:\> $servicehashOutputName Value ---- ----- Name Spooler StartType Automatic State StoppedWe need to add multiple values to the Name Key. If we directly append the value ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
4K+ Views
We will first retrieve the content of the folder using the Get-ChildItem command and then pipeline the Measure-Object command as shown below.Get-ChildItem C:\Temp\ -Recurse | Measure-Object -Property Length -SumOutputCount : 1514 Average : Sum : 372060503 Maximum : Minimum : Property : LengthSo the above output shows that there is ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
9K+ Views
To run Powershell commands from the command prompt or cmd, we need to call the PowerShell process PowerShell.exe.ExampleSee the sample example, C:\> Powershell.exe -Command "Write-Output 'Hello world'" Hello worldSimilarly, you can call any command. We will use another example to get service informationC:\> Powershell.exe -Command "Get-Service Spooler" Status Name ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
2K+ Views
To get the list of empty folder on the windows OS using PowerShell, we can use the below method.gci C:\Temp -Recurse | foreach { if( $_.psiscontainer -eq $true){ if((gci $_.FullName) -eq $null){$_.FullName} } }The above command checks the ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
979 Views
To get the list of empty files in Windows OS using PowerShell, there are two ways, a) Using Length parameter. We will count the length of the file. If it is 0 then the file is empty as shown below.Get-ChildItem C:\Temp\ -Recurse | where{$_.Length -eq 0} | Select @{N='EmptyFiles';E={$_.FullName}}Output:b) Another ... Read More