- 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 2043 Articles for Microsoft Technologies
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
Have we ever wondered, Write-Output and Write-Host both are used to print the strings or the output of the command then what is the difference between them?ExamplePS C:\> Write-Output "Test String" Test String PS C:\> Write-Host "Test String" Test StringThe output remains the same.The first major difference is storing the output using the Pipeline structure. Write-Output and Write-Host both support the pipeline structure for example, Example"Test String" | Write-Output Test String "Test String" | Write-Host Test StringThe output remains the same.The first major difference is storing the output using the Pipeline structure. Write-Output and Write-Host both support the pipeline ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
Foreach-Object -Parallel command was introduced in PowerShell version 7, preview 3, and it is used for the parallel execution of the pipeline input and more details on this have been explained in this article.Please Note: Foreach-Object and Foreach commands are the same but we can’t write Foreach -Parallel command because there is no such command, we need to use the full command, Foreach-Object -Parallel.A simple example of running a parallel object.Example1..10 | ForEach-Object -Parallel{ $_ * 1000 Sleep 1 }Output1000 2000 3000 4000 5000 6000 7000 8000 9000 10000Let's compare the timings with and without -Parallel parameter.Parallel Execution$time1 = Measure-Command { ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
8K+ Views
To use the stopwatch in PowerShell, we need to use [System.Diagnostics.Stopwatch] class.We will create a new object for this class, $stopwatch = [System.Diagnostics.Stopwatch]::new()Below are the members of the above stopwatch mentioned class.PS C:\> $Stopwatch | gm TypeName: System.Diagnostics.Stopwatch Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() Reset Method void Reset() Restart Method void Restart() Start Method void Start() Stop Method void Stop() ToString Method string ToString() Elapsed Property timespan Elapsed {get;} ElapsedMilliseconds Property long ElapsedMilliseconds {get;} ElapsedTicks Property long ElapsedTicks {get;} IsRunning Property bool IsRunning {get;}You can see ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
The ternary operator in PowerShell was introduced with the PowerShell version7.0. The ternary operator has ‘?’ (question mark) symbol and its syntax is, [Condition] ? (output if True) : (output if false)The left side of the ternary operator is condition and the right side is output based on the condition statement. The output from the condition is in the forms of the Boolean, if the condition is true, the True block will be executed and if the condition is false, the False block will be executed. For example, Example$a = 5; $b = 6 ($a -gt $b) ? "True" : ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
10K+ Views
Compare-Object command in PowerShell is used to compare two objects. Objects can be a variable content, two files, strings, etc. This cmdlet uses few syntaxes to show the difference between objects which is called side indicators.=> - Difference in destination object. Compare-Object "World" "Alpha" InputObject SideIndicator ----------- ------------- Alpha => World Compare-Object "World" "woRld" PS C:\> Compare-Object "World" "woRld" -IncludeEqual InputObject SideIndicator ----------- ------------- World ==Please note, Comparison-Object is not case sensitive. For the case-sensitive comparison, use -CaseSensitive parameter.PS C:\> Compare-Object "World" "woRld" -CaseSensitive InputObject SideIndicator ----------- ------------- woRld => World File2.txt ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
13K+ Views
To remove mapped drives from PowerShell on windows systems, you can use both PowerShell and cmd commands.Using the cmd commandYou can use the below command for a single mapped drive-by specifying the disk drive letter or by using the wildcard character (*).To remove a single mapped drive.Examplenet use K: /deleteOutputPS C:\WINDOWS\system32> net use K: /delete K: was deleted successfully.To remove multiple mapped drives together.Examplenet use * /deleteYou need to confirm removing multiple mapped disks together.OutputPS C:\WINDOWS\system32> net use * /delete You have these remote connections: K: \remoteshare\shared M: \remoteshare\shared folder Continuing will cancel the connections. Do you want to continue this operation? (Y/N) [N]: Y The command completed successfully. Using the PowerShell methodTo remove the mapped network drive with PowerShell ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
4K+ Views
You can map the network drive on the local and remote computers using several ways.Using cmd command.You can use the below command to map the network drive, here letter M, and the shared folder on the local computer.Examplenet use M: "\remoteshare\Shared Folder" PS C:\WINDOWS\system32> net use M: Local name M: Remote name \remoteshare\Shared Folder Resource type Disk Status OK # Opens 1 # Connections 1 The command completed successfully.To map on the remote computer.Invoke-Command -ComputerName RemoteComputer -ScriptBlock{net use k: "\remoteshare\shared"} Using the New-PSDrive command.You can map a network drive using ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
17K+ Views
There are few methods to get the mapped network drive using PowerShell.CMD command method.You can use the cmd command net use in PowerShell to get the mapped drives.net useOutputPS C:\WINDOWS\system32> net use New connections will be remembered. Status Local Remote Network ------------------------------------------------------------------------------- OK K: \localhost\shared folder Microsoft Windows Network OK L: \localhost\Shared Microsoft Windows Network The command completed successfully.To get the mapped drives on the remote computer, Invoke-Command -ComputerName RemoteComputer -ScriptBlock{Net use} OrInvoke-Command -ComputerName RemoteComputer -ScriptBlock{Invoke-Expression -Command "Net use"}PowerShell WMI and CimInstance method.You can also use the ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
958 Views
Consider you have multiple outputs to display on the webpage using PowerShell and we will use the Convertto-HTML built-in cmdlet for it but to display them properly, we first need to convert each part into fragment using –Fragment parameter.Let’s just take the simple example without the –Fragment parameter. In the below example, we are going to display the BIOS information, Local disk information, and Automatic but stopped services information.#To get the BIOS information Get-CimInstance Win32_BIOS | Select Name, Manufacturer, SerialNumber, Status, Version | ConvertTo-Html | Out-File ComputerInformation.html #To get the logical disk information Get-CimInstance Win32_LogicalDisk | where{$_.DriveType -eq '3'} | Select DeviceID, @{N='Total Size(GB)';E={[math]::Round($_.Size/1GB, 2)}}, @{N='Free size(GB)';E={[math]::Round($_.Freespace/1GB)}} | ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
4K+ Views
Cascading Style Sheets (CSS) in general used for formatting HTML with styles. It describes how the HTML elements should be displayed.Once we get the output from the Convertto-HTML command, we can use the CSS style to make the output more stylish.Consider we have the below example for converting the services output table to the HTML.ExampleGet-Service | Select Name, DisplayName, Status, StartType | ConvertTo-Html -Title "Services" -PreContent "Services Output" | Out-File Servicesoutput.htmlThe output is simple for the above command in HTML.There are multiple ways to add the CSS style in the above HTML file so the file output becomes more stylish. ... Read More