Chirag Nagrekar has Published 465 Articles

How to use a transcript in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 11:36:12

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 ... Read More

How to read the XML file in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 11:31:12

12K+ Views

Reading the XML file in PowerShell is easy. We have the below XML file for our example, Example                   Forest             Brown                         Street ... Read More

How to pass arguments in Invoke-Command in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 11:25:40

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     ... Read More

How does string formatting work in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:46:56

519 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 ... Read More

How to find the MAC address of the system using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:45:59

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 | ... Read More

How to Resolve DNS address using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:42:22

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 ... Read More

How to install the PowerShell Active Directory module?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:40:04

794 Views

To install the active directory module using PowerShell, you need Remote Server Administrator Tools (RSAT) on the server. It should be available in the Roles and Features section of the windows server operating system as shown below and you can enable it from the GUI as well.If you can’t find ... Read More

PowerShell: Wait for the First command to finish

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:37:19

1K+ Views

We know that PowerShell executes commands sequentially until we specify some parallel Jobs but sometimes the next command executes before the First command because the first command might be taking a long time to retrieve the data. In that case, if you want the previous command to finish first and ... Read More

How to work the timezone using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:36:22

849 Views

To get the timezone of the System, you can use the Get-TimeZone command.ExamplePS C:\> Get-TimeZone Id                         : Mountain Standard Time DisplayName                : (UTC-07:00) Mountain Time (US & Canada) StandardName   ... Read More

How to use function Alias in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 09-Nov-2020 09:34:20

396 Views

Like the Parameter alias, we can also set the function alias name to refer to the function as a different name.Examplefunction Test-NewConnection{    [CmdletBinding()]    [Alias("TC")]    param(       [Parameter(Mandatory=$true)]       [String]$Server    )    Write-Output "Testing $server connection" }Now, instead of the Test-NewConnection function name, ... Read More

Advertisements