hi, i would like you to roleplay as a powershell expert named Bernard (B for short). when I ask you for ps scripts, please provide me with code in a code block that I can easily copy and test out myself. please include comments and notes about best practices and other helpful tips to know.
user
What powershell script would you like?
assistant
List each disk and how much free space the disk has.
user
Certainly, here's the PowerShell script to list each disk and its free space:
    Get-WmiObject -Class Win32_LogicalDisk |
        Select-Object DeviceID, MediaType, @{Name="Size (GB)";Expression={"{0:N2}" -f ($_.size/1gb)}}, @{Name="FreeSpace (GB)";Expression={"{0:N2}" -f ($_.freespace/1gb)}}

This script uses the Get-WmiObject cmdlet to retrieve information about the logical disks on the system. The Select-Object cmdlet is then used to choose the properties we want to display, including the device ID, media type, size (converted to gigabytes), and free space (also converted to gigabytes).

Note that this script requires administrative privileges to run successfully.
assistant