Found 2039 Articles for Microsoft Technologies

How to format the disk using PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:23:31

987 Views

To format the disk using PowerShell, we can use the Format−Volume command. For example, we have to format the E: on the local server then we can use the simple format command as shown below.Format−Volume −DriveLetter E −Force −VerboseTo format the disk with the specific filesystem use the below command.Format−Volume −DriveLetter E −FileSystem NTFS −Full −Force −VerboseThe above command with Format the E drive with the NTFS file system (there are other file systems like FAT, FAT32, exFAT) forcefully.You can even change the label for the drive while formatting using −NewFileSystemLabel command.Format−Volume −DriveLetter E −FileSystem NTFS −NewFileSystemLabel "Temporary Stroage" −Full ... Read More

How to change the local disk name using PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:23:14

4K+ Views

To change the local disk name using PowerShell, we can use the Set−Volume command. For example, we have Drive name F and its volume label is “New Volume” and need to change it to the “Temporary Storage” then we can change the label using its existing volume name or with the Drive letter.To change the volume name with the Drive letter, Set−Volume −DriveLetter 'E' −NewFileSystemLabel 'Temporary Storage'To change it with the existing label, Set−Volume −FileSystemLabel 'New Volume' −NewFileSystemLabel 'Temporary Storage'For the remote system, we can use either Invoke−Command or the CIMSession parameter.For example, $sess = New−CimSession −ComputerName Labmachine2k12 Set−Volume −CimSession ... Read More

How to change the Drive letter using PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:15:34

2K+ Views

To change the drive letter using PowerShell, we can use the Set−Partition command but before that, we need to know which drive letter to change. You can check the drive letter using Windows Explorer, Get−Partition, Gwmi win32_Logicaldisk, or Get−CimInstance Win32_Logicaldisk command.Suppose we have an E: and we need to rename its drive letter to F, so we can use the below command.Set−Partition −DriveLetter 'E' −NewDriveLetter 'F'Make sure that the drive is not in use by Pagefile, open application, or open file from the drive otherwise the drive letter will fail to change.To change the drive letter on the remote computer, ... Read More

How to get the disk information using PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:15:06

7K+ Views

To get the Windows disk information using PowerShell, we can use the WMI command or the CIM class command.With the WMI command, Gwmi Win32_LogicalDiskWith the CIM instance method, Get−CimInstance Win32_LogicalDisk You can see both the outputs are identical. Let’s use one of them.DeviceID DriveType ProviderName VolumeName Size FreeSpace -------- --------- ------------ ---------- ---- --------- C: 3 53317988352 44027125760 D: 5 HRM_SSS_X64FREE_EN-US_DV5 3694962688 0 E: 3 Temporary Storage 10734268416 10238513152Now there are different drive types associated with Windows and they each have an identical number. For example, Drive Type ‘3’ mentions the logical disk. The other types are as below.2 = ... Read More

How to install the Nuget Package using PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:18:40

21K+ Views

Nuget is the package management tool for the .NET and it is similar to PowerShellGet, MSI packages which support several commands and packages to work with PowerShell.NuGet supports Install−Package, Update−Package, Find-Package, and Get−Package command and if Nuget package is not installed in your system, you may not find a package or install any package.For more reference about Nuget, check the websites below.https://www.nuget.orghttps://docs.microsoft.com/en-us/nuget/reference/powershellTo install NuGet, we need to use the Install−PackageProvider command. Use the below command to install the Nuget package.Install−PackageProvider −Name Nuget −ForceOn some machines, you will get the error message regarding downloading the package from the internet. If you ... Read More

Ways to use Where-Object in PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:11:07

2K+ Views

Where−Object or (alias: Where) in PowerShell is used to filter the data output provided through the Pipeline.There are two methods we can use the Where−Object for the pipeline inputs.a. ScriptMethod −In this method, we use ScriptBlock to filter the output with the Property name, value, and the comparison operator.Get−Service | Where−Object{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')}You can also use Alias: Where instead of Where−Object.Get−Service | Where{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')} Other Syntax ‘?’ (Question Mark) can also be used Instead of the Where−Object command.Get−Service | ?{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')}The above commands will get the ... Read More

How to change the color of the PowerShell ISE editor using command?

Chirag Nagrekar
Updated on 18-Jan-2021 07:44:08

2K+ Views

To change the color of the ISE Editor, we need to use $psISE cmdlet which is only available for the ISE editor.Now in the ISE editor, we have many colors some are visible (ScriptPane color, Console Color, etc) and some appear while executing a script (Error, Warning, Verbose). These properties are as below.ErrorForegroundColor : #FFFF9494 ErrorBackgroundColor : #00FFFFFF WarningForegroundColor : #FFFF8C00 WarningBackgroundColor : #00FFFFFF ... Read More

How to change PowerShell ISE font Size using command?

Chirag Nagrekar
Updated on 18-Jan-2021 07:41:03

3K+ Views

To change the font size of the PowerShell ISE editor using the command, we need to use the cmdlet $PSISE which is only loaded inside the PowerShell ISE console. You won’t find it in the main PowerShell console.Once you run this command, there are various properties available. For example, PS C:\> $psISE CurrentPowerShellTab          : Microsoft.PowerShell.Host.ISE.PowerShellTab CurrentFile                   :  Microsoft.PowerShell.Host.ISE.ISEFile CurrentVisibleHorizontalTool  : CurrentVisibleVerticalTool    : Options : Microsoft.PowerShell.Host.ISE.ISEOptions PowerShellTabs                :  {PowerShell 1}You need to select the Options Property and then need to ... Read More

How to traceroute using PowerShell?

Chirag Nagrekar
Updated on 18-Jan-2021 07:38:30

18K+ Views

Traceroute is the way to determine the hopes that the packets are passing through when requested. In the command prompt, that utility is called the tracert and we can also use that utility to trace the network packets. For example, PS C:\> tracert google.com Tracing route to google.com [216.58.203.142] over a maximum of 30 hops: 1    1 ms    1 ms    1 ms 192.168.0.1 2    2 ms    2 ms    2 ms 45.114.51.246 3    8 ms    4 ms    4 ms 103.210.200.141 4    21 ms   *       * 10.10.125.29 5 ... Read More

How to format string using PowerShell?

Chirag Nagrekar
Updated on 18-Jan-2021 07:32:31

6K+ Views

To format a string in a PowerShell we can use various methods. First using the simple expanding string method.PS C:\> $str = 'PowerShell' PS C:\> Write-Output "Hello $str !!!!" Hello PowerShell !!!!Second, using the format method. In this method, we will use the Format function of the String .NET class.PS C:\> $str = "PowerShell" PS C:\> [String]::Format("Hello $str...!!!") Hello PowerShell...!!!The third method using the Format operator. We can use the number format here as shown below.PS C:\> $str = 'PowerShell' PS C:\> "Hello {0}" -f $str Hello PowerShellIf we have multiple variables then we need to increase the numbers inside ... Read More

Advertisements