"Invalid namespace" Error when trying to use NetQosPolicy in Powershell - powershell

Trying to limit the network bandwidth for a certain application, I came across such a thing as NetQosPolicy. I started trying to create new policies through PowerShell, but kept getting this error:
New-NetQosPolicy : New-NetQosPolicy : Invalid namespace string:1 character:1 + New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -Net ... + + CategoryInfo : MetadataError: (MSFT_NetQosPolicySettingData:ROOT/StandardCi...licySettingData) [New-Net QosPolicy], CimException + FullyQualifiedErrorId : HRESULT 0x8004100e,New-NetQosPolicy
I used this code: New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -NetworkProfile All -ThrottleRateActionBitsPerSecond 1200000
I thought I had made a mistake in the syntax and decided to look at the examples on the Microsoft website (https://learn.microsoft.com/en-us/powershell/module/netqos/new-netqospolicy?view=windowsserver2022-ps), but even their examples cause me the same error.
I haven't found a solution to this problem anywhere, so I'm asking on the forum. I will be grateful to anyone who knows how to solve this problem.
(By the way, I get the same error when I try to use the NetSecurity module (for example, the command: New-NetFirewallRule))

You might have a corrupt wmi repo, read this page but start with this check
Check if the repository is corrupted or not by running following command from command prompt with admin rights: winmgmt /verifyrepository

Related

Add-SBHost : The system cannot find the file specified

I am attempting to add a Host to a newly created Windows Service Bus 1.1 farm but regardless of what I do I eternally get the following error:
VERBOSE: [11/16/2018 2:54:06 PM]: Validating input and configuration parameters.
VERBOSE: [11/16/2018 2:54:06 PM]: Installing auto-generated certificate.
VERBOSE: [11/16/2018 2:54:16 PM]: Granting 'Log on as Service' privilege to the run as account.
VERBOSE: [11/16/2018 2:54:16 PM]: Windows Fabric configuration started.
VERBOSE: [11/16/2018 2:54:28 PM]: Windows Fabric cluster manifest generated.
VERBOSE: [11/16/2018 2:54:28 PM]: Running Windows Fabric deployment.
Add-SBHost : The system cannot find the file specified
At line:1 char:1
+ Add-SBHost -SBFarmDBConnectionString "Data Source=MYHOST;Initial C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-SBHost], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.ServiceBus.Commands.AddSBHost
I had been struggling with configuring the initial deployment of the farm because my organization uses Azure AD. I was following this very helpful Blog post to get through the installation and deployment but the issue I am seeing now isn't covered.
A Google of the issue leads me to this page where they talk about inspecting a DLL. I tried inspecting the Microsoft.ServiceBus.Commands.dll from within the Service Bus installation folder but, I'll be honest, I didn't understand enough to know what I was looking for.
Has anyone else run into this issue before? All suggestions of where I can look to find this are very much appreciated!
Based on my research of what is actually happening in Add-SBHost command, this error may occur when:
Code is trying create new temp file in %userprofile%\AppData\Local\Temp directory for something called "ClusterManifest".
Code is trying to execute FabricDeployer.exe (with created "ClusterManifest" file path as parameter) in directory which is defined in registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Service Bus\1.1 for variable WinFabric in folder bin\Fabric\Fabric.Code.1.0. In my case, executable was placed in C:\Program Files\Windows Fabric\bin\Fabric\Fabric.Code.1.0\FabricDeployer.exe
Code is trying to remove temp file (created in 1 point) from %userprofile%\AppData\Local\Temp
After that steps and getting message VERBOSE: [09.08.2019 13:32:26]: Windows Fabric starting. no more file operations should be performed.
What to do?
First of all check if temp file is created in %userprofile%\AppData\Local\Temp directory (sort files by modification date in explorer, run script and wait) - probably file cannot be created because of lack of permissions.
If file is creating properly and has XML inside, then check if Service Fabric is installed and FabricDeployer.exe is present in directory. In my case it wasn't there so i had to remove Windows Fabric and Service Bus. After next installation i made sure that all files were in place.
After these steps script run was successful.
I hope it will help you :)

Azure Add-AzureDisk is not working

I am using PowerShell ISE. When I run Add-AzureDisk
I get a CLI wizard and fill in the DiskName
and I have the vhd file uri in my clipboard (copied from the portal)
When I use the uri without "..." I get:
Add-AzureDisk : Invalid URI: cannot parse the hostname.
At line:1 char:1
Add-AzureDisk
~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Add-AzureDisk], UriFormatException
FullyQualifiedErrorId : System.UriFormatException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.AddAzureDisk
Command
When I do use the "uri here" I get:
Add-AzureDisk : Invalid URI: URI-scheme is invalid. At line:1 char:1
I used this button:
I started to think that my powershell modules are out of date or something, so I ran Get-Module AzureRm.Profile -ListAvailable as suggested here:
Directory: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 4.0.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave,...
But I also have v5 (found this on the docs website):
Get-Module -ListAvailable -Name AzureRm.Resources | Select Version
Version
5.0.0
As you might have guessed, I am more used to the webportal. But I am trying to create a new vm with two unmanaged disks vhd's which are in my blob storage container.
Edit I tried the Azure CLI:
az vm create -n "tmp-vm" -g "resource-tmp" --attach-os-disk "https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd" --size Standard_DS1_v2 --use-unmanaged-disk --os-type windows
and got:
At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "DiskBlobPendingCopyOperation",
"message": "Disk blob https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd is not ready. Copy state: Failed. Please retry when the blob is ready."
}
]
}
} Correlation ID: 0e1231a9-aa0e-4d79-8953-92ea43c658eb
I created the vhd with the powershell commands that I have found here:
https://stackoverflow.com/a/45569760/169714 perhaps that failed? I did not got an error or anything? How can I consolidate it?
edit2 I tried both templates and had a hard time getting the debug info. But I have found the error now. And it is the same as before:
The blob seems to have the expected size. The lease state says available. Last modified date is a second ago, so does that mean that the underlying storing is still in process? I tried to run Get-AzureStorageBlobCopyState -Blob tmpvmosdisk.vhd -Container vhd-containers -WaitForComplete but that gives an error about a non required (and unknown to me) argument:
Get-AzureStorageBlobCopyState : Could not get the storage context. Please pass in a storage context or set the current storage context.
edit 3 data disk seems flushed again. It was 512gb and is now back to zero?
so I got the not ready message again when I wanted to add the vhd as disk...
As Hannel said, Add-AzureDisk is a classic command. You could not use it to create a ARM mode VM.
--attach-os-disk it requires a managed disk, now, you give a unmanaged disk(VHD), so, you get the error log. See this link.
According to your scenario, the easy way is to create VM with a template. You could use this template:Create a Virtual Machine from a User Image.
If you have existing VNet, you also could use this template.
I can highlight multiple issues, i will try to answer all as best as i can.
First, Add Add-AzureDisk is a ASM (Classic Deployment) command but you are mentioning AzureRM Module. Is it an ARM or ASM deployment?
Second, you CLI is ARM deployment, that failed because you copied the VHD and the copy operation is not yet done so you cannot used the VHD. You should be able use the az storage blob show command to validate the VHD copy/move is completed before using VHD.
Hope this helps.

Ansible through WinRM: win_find throws OutOfMemoryException

I'm working on some Ansible playbooks that have to run on Windows Server 2008 with Powershell 3.
As part of one of these playbooks I do a win_find to get a list of files in a directory:
- name: filecheck
win_find:
paths: C:\dev\envs
register: envs
When I try to run the playbook, it runs correctly through preliminary operations (eg printing some debug variables) but then errors out when the above operation is executed:
"module_stderr": "Exception of type 'System.OutOfMemoryException' was thrown.\r\nAt line:60 char:9\r\n+ If (-not $obj.GetType)\r\n+ ~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : OperationStopped: (:) [], OutOfMemoryException\r\n + FullyQualifiedErrorId : System.OutOfMemoryException\r\n \r\n\r\n",
Now I don't see a scenario where a non-recursive find on a folder with three files would be able to consume 150MB of memory, let alone the 2048 that's been allocated to shells over WinRM.
Does anyone know how I can fix this issue or try and find the root cause?

How can I fix this "Set-SecureBootUEFI : Incorrect authentication data: 0xC0000022" error?

I used the tutorial and the PowerShell scripts in UefiSecureBootManualTests.zip(EnableSecureBoot.ps1 and append_LostCA_db.ps1) found here to sign an .efi file and enable SecureBoot to see if the system boots(it all worked well).
Now I'm trying to take the winload file from system32, sign it using the same scripts, and then overwrite the keys and see if SecureBoot lets me boot only with the winload I signed.
This time I am using the same scripts, except I modified Set-SecureBootUEFI command in the append_LostCA_db.ps1 deleting -AppendWrite parameter so it can overwrite.
But now I am receiving an error:
Set-SecureBootUEFI : Incorrect authentication data: 0xC0000022
At F:\SecureBoot\AllowNewCertificate\suprascriu_LostCA_db.ps1:13 char:5
+ Set-SecureBootUEFI -Name db -Time 2011-05-21T13:30:00z -ContentFilePath Lost ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (Microsoft.Secur...BootUefiCommand:SetSecureBootUefiCommand) [Set-Secu
reBootUEFI], UnauthorizedAccessException
+ FullyQualifiedErrorId : SetFWVarFailed,Microsoft.SecureBoot.Commands.SetSecureBootUefiCommand
How can I fix this?
I am using a HP desktop with Win8.1 x64
LATER EDIT: It would REALLY help if someone could give me an unsinged winload for 8.1 x64
One of the things that these signatures tell you is that the content has not been modified(that means it is still secure/valid/trustable). So that is the reason why I could not sign a file already signed(the loader used at boot and signed by Microsoft). That's why I was getting the UnauthorizedAccessException.
There is no workaround for this.

Windows AppFabric - renamed server, config now not loading

My original server was called xyz and the config was as follows:
\xyz\AppFabricConfig\ClusterConfig.xml
We renamed the server and it is now called 123, but the config is still pointing to
\xyz\AppFabricConfig\ClusterConfig.xml
And giving the following error when trying to load:
Use-CacheCluster : ErrorCode<ERRCMS0001>:SubStatus<ES0001>:Error while trying t
o load configuration: An error occurred loading a configuration file: Logon fai
lure: unknown user name or bad password.
(\\xyz\AppFabricConfig\ClusterConfig.xml)
At line:1 char:62
+ Import-Module DistributedCacheAdministration;Use-CacheCluster <<<<
+ CategoryInfo : NotSpecified: (:) [Use-CacheCluster], DataCacheE
xception
+ FullyQualifiedErrorId : ERRCMS0001,Microsoft.ApplicationServer.Caching.C
ommands.UseCacheClusterCommand
I've manually edited the following file:
C:\Windows\System32\AppFabric\DistributedCacheService.exe.config
And set: configuration/dataCacheConfig/clusterConfig connectionString="\123\AppFabricConfig\ClusterConfig.xml"
But its still trying to load from:
\xyz\AppFabricConfig\ClusterConfig.xml
Stumped - close to re-installing, but would really prefer not too!
In hind sight, best way to handle this would've been unconfigure the hosts with remove-cachehost and remove-cacheadmin, rename server and then run config wizard or run add-cachehost and add-cacheadmin.
The connection string is also present in registry, change there also: local machine\software\microsoft\appfabric\v1.0\configuration: connectionstring.
[Edit]
To remove/add the host from cluster configuration, Register-cachehost and unregister-cachehost also need to be run.