Found 989 Articles for Software & Coding

How to delete registry Key using PowerShell?

Chirag Nagrekar
Updated on 31-Oct-2023 22:00:48

51K+ Views

To delete the registry key using PowerShell, we can use the Remove-Item command. Remove-Item command removes the registry key from the path specified. For example, we have the registry key name NodeSoftware stored at the path HKLM, under the Software key.To delete the key we will use the below command.Remove-Item -Path HKLM:\SOFTWARE\NodeSoftware -Force -VerboseWe can also use the Get-Item command to retrieve the Key name and then use the Remove-Item after pipeline.Get-Item HKLM:\SOFTWARE\NodeSoftware | Remove-Item -Force -Verbose

How to delete registry key value (property) using PowerShell?

Chirag Nagrekar
Updated on 08-Feb-2021 07:28:37

10K+ Views

To delete the registry key value using PowerShell, we can use the Remove-ItemProperty command. Suppose we have the registry NodeSoftware and its Property is AppSecurity. We need to delete its key using the Remove-ItemProperty command.PS C:\> Get-Item HKLM:\SOFTWARE\NodeSoftware Hive: HKEY_LOCAL_MACHINE\SOFTWARE Name    Property ----    -------- NodeSoftware    AppSecurity : 1To delete the registry key, PS C:\>Remove-ItemProperty HKLM:\SOFTWARE\NodeSoftware\ -Name AppSecurity -Force -Verbose VERBOSE: Performing the operation "Remove Property" on target "Item: HKEY_LOCAL_MACHINE\SOFTWARE\NodeSoftware\ Property: AppSecurity".You can also delete property by setting the location. For example, ExamplePS C:\> Set-Location HKLM:\SOFTWARE\NodeSoftware PS HKLM:\SOFTWARE\NodeSoftware> Remove-ItemProperty -Path . -Name AppSecurity -Force -VerboseTo remove Item property using Pipeline, Get-Item HKLM:\SOFTWARE\NodeSoftware | Remove-ItemProperty -Name AppSecurity -Force -VerboseRead More

How to dismount the ISO file using PowerShell?

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

3K+ Views

To dismount the ISO file on the Windows Server using PowerShell, we need to use the Dismount−DiskImage command. When you use this command, you need to use the same path used for mounting the disk image.In this example, we have a disk mounted on E: on the local server, that we can check using the windows explorer or cmdlets.We have the source ISO image stored at F: drive, so we can dismount the image using the below command.ISO Disk will be mounted from the E:To dismount the disk on the remote server, we can use the CIMSession command.$sess = New−CimSession ... Read More

How to mount the ISO file using PowerShell?

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

3K+ Views

To mount the ISO file in Windows using PowerShell, we can use the Mount−DiskImage command. The below command will mount the image file stored at the C:\ISO location.Mount−DiskImage −ImagePath "C:\ISOs\Windows_Server_2016_Datacenter_EVAL_en−us_14393_refresh (1).ISO"OutputAttached : True BlockSize : 0 DevicePath : \.\CDROM0 FileSize : 6972221440 ImagePath : C:\ISOs\Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh (1).ISO LogicalSectorSize : 2048 Number : 0 Size : 6972221440 StorageType : 1 PSComputerName :You can also check from Windows Explorer that the disk is mounted.To mount on the remote computer, we can use CIMSession as a remote session and mount the disk.$sess = New−CimSession −ComputerName Labmachine2k12 Mount−DiskImage −CimSession $sess −ImagePath F:\Windows_Server_2016_Datacenter.isoIn the above example, ... Read More

How to convert JSON object to Hashtable format using PowerShell?

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

5K+ Views

PowerShell 7 supports the -AsHashtable parameter in the ConvertFrom−JSON command to convert the JSON to hashtable directly and that is a great feature. Consider we have the below JSON file, We can use the pipeline command ConvertFrom−JSON to convert the JSON file to the custom table format and with the −AsHashtable parameter to convert the custom object to the hashtable.PS C:\Temp> Get-Content .\testsevent.json | ConvertFrom-Json -AsHashtable Name Value ---- ----- Events {602d9444−d2cd−49c7−8624−8643e7171297} DocumentIncarnation 0To retrieve the data, PS C:\Temp> $out = Get−Content .\testsevent.json | ConvertFrom−Json −AsHashtable PS C:\Temp> $out.EventsOutputPS C:\Temp> $out.Events Name Value ---- ----- Description Host server is undergoing ... Read More

How to use the tree command in PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:26:41

9K+ Views

Tree command graphically shows the folder structure of the given drive or a path. It is similar to Get−ChildItem or dir recursive command except this shows the graphical structure. For example, the below command will retrieve the folder structure of C:\VMs includingtree c:\VMsOutputThere are also two other switches supported for this command. They will appear in the help section of this command.c:\>tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters.This command is a cmd utility ... Read More

How to change the TLS version in PowerShell?

Chirag Nagrekar
Updated on 25-Jan-2021 07:26:56

3K+ Views

Transport Layer Security known as TLS is a very important part while using URI commands such as Invoke−WebRequest or Invoke−Restmethod commands and package commands such as Find−Package or Install−Package because they interact on the internet and PowerShell needs TLS1.2 version for that.We may get the below errors when we use the lower TLS version.WARNING: Unable to download the list of available providers. Check your internet connection. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. Find-Package : No match was found for the specified search criteria and package nameTo resolve the above error, we need to change the TLS version. To check ... Read More

How to format the disk using PowerShell?

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

822 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

3K+ 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

Advertisements