Category: Power Shell

ValidateNotNullOrEmpty

[ValidateNotNullOrEmpty()] is a PowerShell parameter-validation attribute. It rejects values that are: Example: Valid call: Output: Invalid empty value: Invalid null value: Why combine it with Mandatory? requires the parameter to be supplied. requires the supplied value to contain something. They are commonly used together: Array example Call: Important limitation A string containing only spaces is …

Continue reading

Write-Error

Write-Error in PowerShell Write-Error writes an error message to PowerShell’s error stream. By default, it creates a non-terminating error. That means PowerShell displays the error, but usually continues with the next command. Typical result: Make it terminating Use: Example: Now the error stops normal execution. Use with try/catch Possible output: Without -ErrorAction Stop, the catch …

Continue reading

Terminating error vs non-terminating error

Terminating error vs non-terminating error in PowerShell Non-terminating error A non-terminating error reports a problem but allows PowerShell to continue running the remaining commands. Example: Possible output: The file-reading command failed, but PowerShell still ran the next line. Common examples include: By default, many PowerShell cmdlets generate non-terminating errors. Terminating error A terminating error stops …

Continue reading

Understanding Host-Only Networking in Oracle VirtualBox: Concepts, Tools, IP Addressing, DHCP, and Practical Options

Ref: Oracle VirtualBox User Guide: VirtualBox supports configurable virtual network cards per VM, host-only networking connects VMs with each other and the host while keeping them away from the outside network, and VirtualBox includes a DHCP server for host-only/internal networks. (VirtualBox) (VirtualBox) Introduction Oracle VirtualBox provides several networking modes for virtual machines. Each mode answers …

Continue reading

Why a DHCP server join the Active Directory

Authorizing a DHCP server in Active Directory means: “This DHCP server is approved by the domain to give IP addresses to clients.” In a Windows AD domain, a domain-joined DHCP server must be authorized before it can start leasing IP addresses. Microsoft’s Add-DhcpServerInDC cmdlet adds the DHCP server to the list of authorized DHCP servers …

Continue reading

How to Install DHCP role

Ref: AI Tools, ChatGPT : As is To install the DHCP Server role on Windows Server 2019, use Windows PowerShell as Administrator on the server VM, not the client VM. 1. Open PowerShell as Administrator On the Windows Server VM: 2. Check whether DHCP is already installed If it is not installed, you may see: …

Continue reading

Power Shell: DHCP Server and Client

Authorize DHCP server in Active Directory if domain joined. The lab includes this wording: Authorize the DHCP server so it can lease addresses in an AD domain environment.If your lab is not domain joined, document that authorization was not applicable and continue only if instructed. The commands included are: the server listed as an authorized …

Continue reading

How to? Disable VirtualBox DHCP for host-only network

Ref: AI Tools, ChatGPT, Similar “Disable VirtualBox DHCP for host-only network” means: Why this matters In your DHCP lab, students are installing and configuring DHCP Server on Windows Server 2019. But VirtualBox host-only networks can also have their own DHCP server. If VirtualBox DHCP is enabled, then the client VM may get an IP address …

Continue reading

DHCP: Powershell Commands

Commands that work in Windows PowerShell 5.1 These DHCP/networking commands are intended for Windows Server PowerShell: Install-WindowsFeature DHCPInstall-WindowsFeature DHCP -IncludeManagementToolsImport-Module DHCPServerAdd-DhcpServerv4ScopeSet-DhcpServerv4OptionValueGet-DhcpServerv4ScopeGet-DhcpServerv4LeaseGet-DhcpServerInDCAdd-DhcpServerInDCRestart-Service DHCPServerGet-Service DHCPServer Related: Get-NetAdapterGet-NetIPAddressNew-NetIPAddressSet-DnsClientServerAddressGet-DnsClientServerAddressipconfig /all

CmdletBinding

Ref: AI Tools/ChatGPT [CmdletBinding()] turns a normal PowerShell function into an advanced function. That means the function behaves more like a real PowerShell cmdlet. Basic example Normal function: Advanced function: What [CmdletBinding()] does It gives your function cmdlet-style behavior, such as: Feature Meaning Common parameters Allows parameters like -Verbose, -Debug, -ErrorAction Better parameter handling Works …

Continue reading