Getting event Id 3 and 4 if we set SPN .for setspn -s http/netbiosname serviceaccount
getting WinRM error if we want to export programs and features through powershel for PI servers
I am not sure how this issue relate to PI, so please provide some more context on this issue.
In general, if you are using Get-WmiObject to get the list with PowerShell, I would suggest consulting the Microsoft documentation on the different Authentication and Impersonation switches, especially if you are connecting to a remote machine.
As far as setspn -s http/netbiosname serviceaccount, are you performing the operation as part of a PI Vision/WebAPI/Coresight configuration. If so, what errors do you see? Do you have the appropriate privileges on the domain to create SPNs? You may want to involve one your domain admins.
Do you have a custom HTTP SPN registered to a domain account on the machine you are trying to connect to? The issue you have encountered could be a known difficulty when HTTP SPNs are registered for domain accounts. While these SPNs are required in order to run PI Vision/Web API as custom accounts, they interfere with Powershell remoting because WinRM uses the HTTP SPN in order to acquire Kerberos tickets to authenticate to the target server on which you are trying to run a command.
A workaround could be to create a port-specific SPN like such:
SetSPN.exe -s HTTP/$($env:COMPUTERNAME):5985 $env:COMPUTERNAME
SetSPN.exe -s HTTP/$($env:COMPUTERNAME).$($env:USERDNSDOMAIN):5985 $env:COMPUTERNAME
Then create a PSSession object using the -IncludePortInSPN parameter.
$sessionOptions = New-PSSessionOption -IncludePortInSPN Enter-PSSession -Computername <computername> -SessionOption $sessionOptions
The difficulty with this is that if you this change to your script is that it will require any machine to have the port-specific SPN created so this might require a separate fork of your script.
Retrieving data ...