-
Notifications
You must be signed in to change notification settings - Fork 13
Get‑ComputerName
Returns the computer name cross-plattform.
Get-ComputerName [-FullyQualifiedDomainName] [<CommonParameters>]
Returns the computer name cross-plattform.
The variable $env:COMPUTERNAME
does not exist cross-platform which hinders development and testing on
macOS and Linux.
Instead this command can be used to get the computer name
cross-plattform.
Get-ComputerName
Returns the computer name regardless of platform.
Get-ComputerName -FullyQualifiedDomainName
Returns the fully qualified domain name regardless of platform.
Returns the fully qualified domain name (FQDN) instead of just the computer name.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
The function uses [System.Environment]::MachineName for the short computer name, which works consistently across all platforms where PowerShell runs.
When the FullyQualifiedDomainName switch is used, the function attempts to retrieve the FQDN using [System.Net.Dns]::GetHostByName() which can resolve the full domain name when the system is properly configured with DNS.
If DNS resolution fails or no domain is configured, the function will fall back to returning the short computer name even when FQDN is requested.
- Assert-BoundParameter
- Assert-ElevatedUser
- Assert-IPAddress
- Assert-Module
- Compare-DscParameterState
- Compare-ResourcePropertyState
- ConvertFrom-DscResourceInstance
- ConvertTo-CimInstance
- ConvertTo-HashTable
- Find-Certificate
- Format-Path
- Get-ComputerName
- Get-DscProperty
- Get-EnvironmentVariable
- Get-FileProductVersion
- Get-LocalizedData
- Get-LocalizedDataForInvariantCulture
- Get-PSModulePath
- Get-RegistryPropertyValue
- Get-TemporaryFolder
- Get-UserName
- New-ArgumentException
- New-ErrorRecord
- New-Exception
- New-InvalidDataException
- New-InvalidOperationException
- New-InvalidResultException
- New-NotImplementedException
- New-ObjectNotFoundException
- Remove-CommonParameter
- Set-DscMachineRebootRequired
- Set-PSModulePath
- Test-AccountRequirePassword
- Test-DscParameterState
- Test-DscProperty
- Test-IsNanoServer
- Test-IsNumericType
- Test-ModuleExist
- Test-PendingRestart