- 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
![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)
954 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
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
HTML is another form of output in PowerShell. It is the rich form of output and you can use various CSS styles to make the output more interactive. We will use the Convertto-HTML cmdlet to convert the output in the HTML format.Here is the Syntax of the Convertto-HTML cmdlet.ExampleConvertTo-Html [-InputObject ] [[-Property] ] [[-Body] ] [[-Head] ] [[-Title] ] [-As ] [-CssUri ] [-PostContent ] [-PreContent ] [-Meta ] [-Charset ] [-Transitional] [] ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
Transcript in Powershell is like a recording session. So whenever you start a transcript in PowerShell, it starts recording your commands and outputs and doesn't matter if there is any error output, it gets recorded too. To start the transcript, you need to run Start-Transcript command at the beginning, and then whatever you write, it will get recorded.To start the recording, you need to write Start-Transcript command and have to give the path for the transcript as shown in the below example, ExampleStart-Transcript -Path C:\Temp\sessionrecord.txtOnce you enter the above command you will get the message as shown below.Start-Transcript -Path .\Sessionrecording.txtOutputPS E:\scripts\Powershell> Start-Transcript -Path .\Sessionrecording.txt Transcript started, output file is .\Sessionrecording.txtBelow is the ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
12K+ Views
Reading the XML file in PowerShell is easy. We have the below XML file for our example, Example Forest Brown Street Multi Forest Yellow Suppose this file is saved as Animals.xml to our current path and to read this XML file we ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
13K+ Views
To pass the argument in the Invoke-command, you need to use -ArgumentList parameter. For example, we need to get the notepad process information on the remote server.ExampleInvoke-Command -ComputerName Test1-Win2k12 - ScriptBlock{param($proc) Get-Process -Name $proc} - ArgumentList "Notepad"OutputHandles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName PSComputerName ------- ------ ----- ----- ------ -- -- ----------- -------------- 67 8 1348 7488 0.08 104 notepad Test1-Win2k12In the above example, we are passing "Notepad" name as the argument to the command and the same has been caught by the $proc variable inside Param().If you have the multiple, check the below command to pass the multiple parameters.ExampleInvoke-Command ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
520 Views
To format string in PowerShell, you can use -F operator. When you use -F format, you need to provide the argument number in the curly brackets.ExamplePS C:\> $Str = "Hello PowerShell" PS C:\> "{0}" -f $str Hello PowerShellFor the multiple values, PS C:\> $Str = "Hello PowerShell" PS C:\> $str1 = "Rockstart" PS C:\> "{0} says {1}" -f $Str, $str1 Hello PowerShell says RockstartFrom the above example, we understood if we need to get the output for multiple variables using the -F operator then we can increment the number in curly brackets.To use the above output with the Write-Output command, ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
4K+ Views
There are several ways to find the MAC address (Physical Address) of the system using PowerShell.Using the Get-NetAdapter commandUsing this command, we can retrieve the MAC address of the network adapter.Using GetMac commandIpconfig commandWe need to use Ipconfig /all to retrieve the mac address of all the adapters.ExampleIpconfig /all | Select-String -Pattern "Description","Physical"Output
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
15K+ Views
To resolve the DNS address using PowerShell, we need to use the Resolve-DNS address command. This command works similarly to Nslookup command.To resolve the A record (Name -> IP), you can directly provide the hostname and by default, it will retrieve all the records for the particular address.ExampleResolve-DnsName -Name Test1-win2k12OutputName Type TTL Section IPAddress ---- ---- --- ------- --------- Test1-Win2k12.labdomain.local A 1200 Answer 192.168.0.107-Name parameter doesn’t accept the multiple-input. Only the single ... Read More