Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bits issue? #206

Open
CiREdrol opened this issue Nov 14, 2022 · 2 comments
Open

Bits issue? #206

CiREdrol opened this issue Nov 14, 2022 · 2 comments

Comments

@CiREdrol
Copy link

CiREdrol commented Nov 14, 2022

Forgive me if this is not an issue with the script however I'm not sure what is wrong. Fors some reason I'm getting BITS issues when I download. I'm using powershell 7.3 with lasted WMF 5.1 installed. BITS transfers done manually seem to work without issue.

InvalidOperation:
Line |
5 | [Microsoft.BackgroundIntelligentTransfer.Management.BitsJob[] .
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [Microsoft.BackgroundIntelligentTransfer.Management.BitsJob].

PS C:\temp> Save-KbUpdate -Name KB4057119 -Verbose
VERBOSE: [15:20:03][Save-KbUpdate] Processing default parameter set
VERBOSE: [15:20:03][Save-KbUpdate] Source set to Database
VERBOSE: [15:20:03][Get-KbUpdate] Source set to Database
VERBOSE: [15:20:03][Get-KbItemFromDb] Processing KB4057119
VERBOSE: [15:20:03][Get-KbItemFromDb] Query: select *, NULL AS SupersededBy, NULL AS Supersedes, NULL AS Link from kb where UpdateId in (select UpdateId from kb
where UpdateId = 'kb4057119' or Title like '%kb4057119%' or Id like '%kb4057119%' or Description like '%kb4057119%' or MSRCNumber like '%kb4057119%')
VERBOSE: [15:20:04][Get-KbItemFromDb] Found 1 in the database for kb4057119
VERBOSE: [15:20:04][Save-KbUpdate] Adding sqlserver2016-kb4057119-x64_c6f298b1e0d79c208f59590354823ebefffdae60.exe to download queue
VERBOSE: [15:20:04][Save-KbUpdate] Starting job process
InvalidOperation:
Line |
5 | [Microsoft.BackgroundIntelligentTransfer.Management.BitsJob[] .
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [Microsoft.BackgroundIntelligentTransfer.Management.BitsJob].
PS C:\temp> get-bitstransfer

JobId DisplayName TransferType JobState OwnerAccount


4f8d7088-058a-4213-a5e9-fd83fb3618f3 BITS Transfer Download Transferring WIN-

PS C:\temp> $error[0] | select *

PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: Unable to find type [Microsoft.BackgroundIntelligentTransfer.Management.BitsJob].
at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)
at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)
at System.Management.Automation.Language.Compiler.GetAttribute(TypeConstraintAst typeConstraintAst)
at System.Management.Automation.Language.Compiler.GetRuntimeDefinedParameter(ParameterAst parameterAst, Boolean&
customParameterSet, Boolean& usesCmdletBinding)
at System.Management.Automation.Language.Compiler.GetParameterMetaData(ReadOnlyCollection1 parameters, Boolean automaticPositions, Boolean& usesCmdletBinding) at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata() at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized) at System.Management.Automation.PSScriptCmdlet..ctor(ScriptBlock scriptBlock, Boolean useNewScope, Boolean fromScriptFile, ExecutionContext context) at System.Management.Automation.CommandProcessor.Init(IScriptCommandInfo scriptCommandInfo) at System.Management.Automation.CommandDiscovery.GetScriptAsCmdletProcessor(IScriptCommandInfo scriptCommandInfo, ExecutionContext context, Boolean useNewScope, Boolean fromScriptFile, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(FunctionInfo functionInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal sessionState) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable1 useLocalScope, SessionStateInternal sessionState)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements,
CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][]
pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : Microsoft.BackgroundIntelligentTransfer.Management.BitsJob
CategoryInfo : InvalidOperation: (Microsoft.Backgroun..Management.BitsJob:TypeName) [], RuntimeException
FullyQualifiedErrorId : TypeNotFound
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Save-KbUpdate, : line 311
at , : line 1
PipelineIterationInfo : {}

PS C:\temp>

@CiREdrol
Copy link
Author

CiREdrol commented Nov 14, 2022

I'm testing again with 5.1...

It works as expected with Powershell 5.1. Not sure why my Powershell 7.3 didn't want to work with BITS..

However, when testing the get-kbneededupdate with scanfile I continually get need Administrator to execute. Whats strange is the progress indicator starts and then quits at around 30% with the following error about needing Admin? Strange. Im running in Administrator..

PS C:\TEMP> Get-KbNeededUpdate -scanfilepath c:\temp -Verbose
VERBOSE: [14:46:11][Get-KbNeededUpdate] Adding job for WIN-*********
VERBOSE: [14:46:11][Start-JobProcess] Processing jobs
WARNING: You must run this command as administator in order to perform the task
VERBOSE: [14:46:23][Start-JobProcess] Finished getting needed updates on WIN-**********

PS C:\TEMP> ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Securit
y.Principal.WindowsBuiltInRole] "Administrator")
True

Also, all my execution policies are properly set. I tested this on a few machines. Same result.

Something to do with the Start-JobProcess function? Wouldn't this "job" also runas Administrator??

@CiREdrol
Copy link
Author

Ok so, I read the wiki section and I noticed one of your Parameters was -scanfile and not -scanfilepath. This piqued my curiosity. So I tested with

Get-KbNeededUpdate -scanfile c:\temp
result: Did not work

Get-KbNeededUpdate -scanfilepath c:\temp
result: Did not work

However, when specifying the actual filename it worked without issue!
Get-KbNeededUpdate -scanfile c:\temp\wsusscn2.cab

and

Get-KbNeededUpdate -scanfilepath c:\temp\wsusscn2.cab

Is this a bug? or...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant