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

prerequirements_AsAdmin.ps1 is not recognized #11

Open
aollivierre opened this issue Mar 6, 2023 · 0 comments
Open

prerequirements_AsAdmin.ps1 is not recognized #11

aollivierre opened this issue Mar 6, 2023 · 0 comments

Comments

@aollivierre
Copy link

. : The term '.\source\ressources\prerequirements_AsAdmin.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At C:\Code\Intune-Win32-Deployer\INSTALL_Intune-Win32-Deployer.ps1:142 char:11
+         . ".\source\ressources\prerequirements_AsAdmin.ps1" -choco $( ...
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\source\ressou...nts_AsAdmin.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

To fix this issue please consider adding the following code block the to the beginning of your script

#startregion
 ##Variables: Exit Code
   [Int32]$mainExitCode = 0

 ##Variables: Environment
   If (Test-Path -LiteralPath 'variable:HostInvocation') {
       $InvocationInfo = $HostInvocation
   }
   Else {
       $InvocationInfo = $MyInvocation
   }
   [String]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

   ## Dot source the required App Deploy Toolkit Functions
   Try {
       [String]$IntuneWin32DeployerMain = "$scriptDirectory\source\ressources\prerequirements_AsAdmin.ps1"
       If (-not (Test-Path -LiteralPath $IntuneWin32DeployerMain -PathType 'Leaf')) {
           Throw "Module does not exist at the specified location [$IntuneWin32DeployerMain]."
       }
       Else {
           . $IntuneWin32DeployerMain
       }
   }
   Catch {
       If ($mainExitCode -eq 0) {
           [Int32]$mainExitCode = 60008
       }
       Write-Error -Message "Module [$IntuneWin32DeployerMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
       ## Exit the script, returning the exit code to SCCM
       If (Test-Path -LiteralPath 'variable:HostInvocation') {
           $script:ExitCode = $mainExitCode; Exit
       }
       Else {
           Exit $mainExitCode
       }
   }

   #endregion

then update the following line

. ".\source\ressources\prerequirements_AsAdmin.ps1" -choco $(if($install_choco -eq "y"){$true}else{$false}) -winget $(if($install_winget -eq "y"){$true}else{$false})

to

. "$IntuneWin32DeployerMain" -choco $(if($install_choco -eq "y"){$true}else{$false}) -winget $(if($install_winget -eq "y"){$true}else{$false})

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