Sunday, August 6, 2023

How to get New GUID in bat programming



We can generate new GUID using command let GUID class in Powershell  

```sh
New-GUID

[guid]::NewGuid().ToString()
```

We can leverage invoking poweshell from batch programming 

```sh

POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"


FOR /F %a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO ( SET NEWGUID=%a )
echo %NEWGUID%

```

No comments:

Post a Comment