Convert batch file to Powershell RRS feed

  • Question

  • I have a batch file I used for years but is now blocked by McAfee. It is blocking the usage of the wmic command so I'm trying to find an alternative in Powershell for the wmic command the a powershell script to replace my batch file. I don't know much about Powershell, so if there is someone who could give me the powershell version of what I need to do would be much appreciated. Time is of the essence as I have not found a fast and practical way around this yet.WDK6

    The batch file basically exports a registry key from a remote station on our network and saves that file to its C:\Temp directory so it exports faster and I only have to get the registry key from their C:\Temp directory. Here is an example:

    wmic /node:OT103706 process call create "reg export \"HKEY_USERS\S-1-5-21-922368595-526787211-398547282-3567\Software\Microsoft\Office\16.0\" b:\Temp\testing.reg"

    Saturday, October 24, 2020 11:25 AM

All replies

  • Hi Warrior55, you can check the help with following command in PowerShell.

    PS> help registry

    For more details, you should ask your question to appropriate community because this forum is for Microsoft Small Basic.  Thanks.

    Nonki Takahashi

    Monday, October 26, 2020 1:03 PM
  • The PowerShell command Get-ItemProperty can return all the values in a Windows registry node.

    If you want to pull specific node values, you can PIPE the results from the first command into another PowerShell command Select-Object

    Here is an example line to get the current Windows build and release ID from the registry:

    Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'|select-object CurrentBuild,ReleaseID

    If you want to send the results to a file, just add another PIPE to the end, and this command becomes:

    Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'|select-object CurrentBuild,ReleaseID|Out-File -FilePath d:\OUTPUT.txt
    Notice that the primary registry hive is abbreviated.  Also, HKEY_Current_User is contains all the settings for the currently logged in user.  You may find that easier to search.
    Saturday, October 31, 2020 9:22 AM