Search notes:
PowerShell: create a global variable in a function
Sometimes, there is a requirement to create a (global) variable within a function. This can be achieved by prefixing the variable name with global:
:
function create-global-var() {
$global:num = 42
$global:txt ='Hello world'
}