Tag: PowerShell 5

PowerShell New-Guid

Create GUID on Windows using PowerShell

For many different scenarios, you need to create or generate a new GUID on Windows. With PowerShell, you can simply create and generate a new GUID on Windows, but also on Linux.

Create GUID using .NET

Before we had this cmdlet we had to use the .NET command to create a new GUID:

[guid]::newguid()

Create and generate GUID on Windows using PowerShell

PowerShell version 5 brings a lot of new cmdlets that make our lives easier and our code cleaner. One of them is the New-GUID cmdlet, which allows you to easily create a new GUID using PowerShell on Windows. Now with PowerShell 5 or higher, we can use simply the new cmdlet:

New-Guid

You can read more about the cmdlet here on Microsoft Docs.

Conclusion

I hope this does the trick for you and helps you with PowerShell going forward. Let me know in the comments if you have any questions. Also, check out my blog post on how to install and update PowerShell 7.



PowerShell New-TemporaryFile

Create a tempfile with PowerShell

When I was using PowerShell in the early stages it was limited in some features, now with PowerShell version 5 Microsoft added some great new features to it. This time it’s about creating a tempfile. I already wrote a blog post in 2011 how you can create a tempfile in older version of PowerShell using .NET:

 
$tempFile = [System.IO.Path]::GetTempFileName()

With PowerShell 5 you got a native cmdlet for this:

 
$tempFile = New-TemporaryFile


PowerShell Get-Clipboard

Get and Set Clipboard using PowerShell

PowerShell was always a mighty tool to automate stuff, hut with the first versions we were limited in some functionally. With the release of version 3 and 4 PowerShell got even more powerful. With the latest PowerShell version 5, which is included in Windows Server 2016 and Windows 10 and also can be downloaded for older versions of Windows, Microsoft added some cool new functionality. The first things I am writing about are the Set-Clipboard and Get-Clipboard cmdlets. The cmdlets allow you to get access to the clipboard of your Windows machine.

For example, if you use CTRL + C or Copy the files from explorer:

Get-Clipboard File Explorer

You can use this cmdlet:

Get-Clipboard -Format FileDropList

PowerShell Get-Clipboard

This also works of course with other file types:

Get-Clipboard -Format Image

PowerShell Get-Clipboard Image

This is a great new addition to PowerShell!