You can use Split-Path to get the folder name from Get-Locationwith -Leaf:
PS C:\temp> Get-Location
Path
----
C:\temp
PS C:\temp> Split-Path -Path (Get-Location) -Leaf
temp
We can also use the automatic variable $PWD to get the current directory:
PS C:\temp> Split-Path -Path $pwd -Leaf
temp
Or using the automatic variable $PSScriptRoot, which uses the current directory the script is being run in:
Split-Path -Path $PSScriptRoot -Leaf
From the documentation for -Leaf:
Indicates that this cmdlet returns only the last item or container in the path. For example, in the path C:\Test\Logs\Pass1.log, it returns only Pass1.log.
Additionally, as @Scepticalist mentioned in the comments, we can use Get-Item and select the BaseName with Select-Object from a specific folder(instead of just the current working directory):
PS C:\> Get-Item -Path c:\temp | Select-Object -Property BaseName
BaseName
--------
temp
Or just select the BaseName property directly with Member Enumeration(PowerShell v3+):
PS C:\> (Get-Item -Path C:\temp).BaseName
temp