- Unblock-File
- Error when running Import-Module
- Unblock a script to run it without changing the execution policy
If you encounter an Access to path denied error during the uninstall process, even with Administrator privileges, it typically stems from issues with folder ownership. To resolve this, you'll need to reassign ownership to an account with administrative privileges. You can accomplish this using the takeown
command.
Example:
takeown /f "C:\ProgramData\containerd" /r /d Y
After successfully changing the ownership, you can proceed to remove the folder manually.
If the issue persists, navigate to the folder's properties and choose the option to Replace all child object permission entries with inheritable permission entries from this object
. This action will apply the inheritable permissions set on this folder to all sub-folders and files within it.
- Navigate to the folder.
- Right-click on the folder and choose Properties.
- Go to the Security tab.
- Click on Advanced.
- In the Advanced Security Settings, select the option
Replace all child object permission entries with inheritable permission entries from this object
. - Apply the changes and confirm.
Ensure 'Hyper-V Host Compute Service' Windows features are enabled.
Get-WindowsOptionalFeature -Online | `
Where-Object { $_.FeatureName -match "Microsoft-Hyper-V(-All)?$" } | `
Select-Object FeatureName, Possible, State, RestartNeeded
To enable a feature:
Enable-WindowsOptionalFeature -Online -FeatureName '<Feature-Name-Here>' -All -NoRestart
# Restart device to apply changes
# Restart-Computer
Restart the operating system to apply changes.
The built-in HostNetworkingService
PowerShell module does not include the New-HNSNetwork
command. This command is available through the HNS module.
You can download it directly from the microsoft/sdn repository.
Tip
The hns.psm1
file should be saved in a directory that is included in the $env:PSModulePath
environment variable.
In the example below, the module is saved in the "Current User, Current Host" profile directory. Read more about PowerShell profiles.
$dirPath = (New-Item -Path "$(Split-Path $PROFILE.CurrentUserCurrentHost)/Modules/HNS" -ItemType Directory -Force).FullName
$Uri = 'https://raw.githubusercontent.com/microsoft/SDN/dd4e8708ed184b49d3fddd611b6027f1755c6edb/Kubernetes/windows/hns.v2.psm1'
Invoke-WebRequest -Uri $Uri -OutFile "$dirPath/hns.psm1"
After installing the module, import it into your session:
Tip
Ensure the Execution Policy is set correctly to import the module.
# Check if the module is installed
Get-Module -Name HNS -ListAvailable -Refresh
# Import the module
Import-Module HNS
Caution
We do not recommend using the third-party HNS module available in the PowerShell Gallery. This module is NOT maintained and signed by Microsoft and may not be up-to-date with the latest changes in the HNS module. Microsoft does NOT take any responsibility for issues that may arise from installing and/or execution of commands in any third-party modules/scripts. Install the third-party HNS module at your own risk!