I do have a problem getting the MicrosoftTeams module loaded in PowerShell. I downloaded and imported the module with AllSigned authorization (no errors):
PS C:\WINDOWS\system32> Install-Module -Name MicrosoftTeams
PS C:\WINDOWS\system32> Import-Module MicrosoftTeams
Checking, whether the Module is loaded correctly, I also printed the available modules where it is displayed with the current version number:
PS C:\WINDOWS\system32> get-module -listavailable
Verzeichnis: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 1.1.4 MicrosoftTeams {Add-TeamUser, Connect-MicrosoftTeams, Disconnect-Microsof...
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remov...
Now, I wanted to connect to the Teams using the cmdlet Connect-MicrosoftTeams which is explicitly listed as one of the exported cmdlets in this imported module. But somehow, PowerShell does not find the command:
PS C:\WINDOWS\system32> Connect-MicrosoftTeams
Connect-MicrosoftTeams : Die Benennung "Connect-MicrosoftTeams" wurde nicht als Name eines Cmdlet, einer Funktion,
einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der
Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
In Zeile:1 Zeichen:1
+ Connect-MicrosoftTeams
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-MicrosoftTeams:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[Excuse the German: It reads: The name was not recognized as cmdlet or name of a function. But you probably know the message if you use PS]
Now, my question is: How can I get PS to recognize the command and how do I find out where the error lies? Is there a command to list the currently running scripts and available commands? Or is there a possibility to force the script to be executed?
I can see the output shows you have installed the module successfully. However, it seems to have some problem. I suggest you re-install it to see how it goes:
Run Windows PowerShell as an administrator
Run the command Uninstall-Module MicrosoftTeams,close PowerShell and re-open a new
elevated PowerShell session
Run the command Install-Module MicrosoftTeams,related doc.
https://learn.microsoft.com/en-us/microsoftteams/teams-powershell-install
After it is installed successfully,please Close PowerShell and re-open a new elevated PowerShell session as an administrator,run Connect-MicrosoftTeams again and see whether it works now. If the same issue persists,attach the screenshot of the entire output for further check.
I had to install the "Skype for Business Online, Windows PowerShell Module" to get Connect-MicrosoftTeams
https://www.microsoft.com/en-us/download/details.aspx?id=39366
Related
regarding a missing AppxPackage error on the last official Win 10 LTSC-Release I want to automatically install it in the post setup of Windows setup processing: Out of Box Experience (OOBE), the first boot UI. Therefore, I have the .appx file and put the following line in the SetupComplete.cmd:
powershell.exe -ExecutionPolicy bypass -Command "Add-AppxPackage %WINDIR%\Setup\Files\Microsoft.VCLibs.140.00_14.0.30704.0_x64__8wekyb3d8bbwe.appx" >> %WINDIR%\Setup\Files\log.txt
I am able to execute this line manually in a non-elevated PowerShell console but unfortunately, this is not working automatically within the Windows Setup processing as it says in the log (sorry, it is German):
Add-AppxPackage : Fehler bei Bereitstellung. HRESULT: 0x80073CF9,
Fehler bei der Installation. Wenden Sie sich an den
Softwarehersteller. (Ausnahme von HRESULT: 0x80073CF9) Der
Bereitstellungsvorgang Add fr das Paket
"Microsoft.VCLibs.140.00_14.0.30704.0_x64__8wekyb3d8bbwe" von der
Installationsanforderung
"Microsoft.VCLibs.140.00_14.0.30704.0_x64__8wekyb3d8bbwe.appx" wurde
abgelehnt, da dieser Vorgang mit dem lokalen Systemkonto nicht
ausgefhrt werden darf. HINWEIS: Wenn Sie weitere Informationen
wnschen, suchen Sie im Ereignisprotokoll nach [ActivityId]
895ecdc3-eb9b-0002-0fcf-5e899bebd701, oder verwenden Sie die
Befehlszeile Get-AppxLog -ActivityID
895ecdc3-eb9b-0002-0fcf-5e899bebd701 In Zeile:1 Zeichen:1
Add-AppxPackage C:\Windows\Setup\Files\Microsoft.VCLibs.140.00_14.0.3 ...
+ CategoryInfo : WriteError: (C:\Windows\Setu...kyb3d8bbwe.appx:String) [Add-AppxPackage],
IOException
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand
Why is the local system account not able to install that package?
MSIX/AppX application packages are installed separately for each Windows user account - the app files are extracted to a central system location, but the registration of the app with the system has to be done for each user. I don't know why the Local System account is specifically banned from installing packages, but I can guess why that is so: it doesn't make sense for app packages to be installed for a user account that doesn't even represent a real person, let alone one that can login to the device.
If you'd like the package you're trying to install to be available to all users on the computer, you should "provision" the package using the Deployment Imaging and Servicing Manager (DISM). Provisioned packages will be installed automatically for all existing user accounts the next time they login, and for all newly created accounts on first login.
With DISM's /Add-ProvisionedAppXPackage subcommand (PowerShell version: Add-AppXProvisionedPackage), you can add a provisioned package to the running copy of Windows. I recommend you not do this in OOBE but earlier, in sysprep audit mode:
:: .bat or .cmd batch file would look like this:
Dism.exe -online -add-provisionedAppxPackage -packagePath:X:\whatever.appx
# PowerShell .ps1 script would look like this:
Add-AppXProvisionedPackage -Online -PackagePath X:\whatever.appx
You could also use DISM to provision the package in a Windows installation image (.WIM file) before Windows even gets installed on the device:
:: use Dism.exe -get-wiminfo to find the WIM's "index" number for the Windows edition or custom image you want to change
Dism.exe -mount-wim -wimFile:D:\sources\install.wim -index:1 -mountDir:X:\WimMount
Dism.exe -image:X:\WimMount -add-provisionedAppxPackage -packagePath:X:\whatever.appx
Dism.exe -unmount-wim -mountDir:X:\WimMount -commit
# use Get-WindowsImage to find the index for the image you want to change
Mount-WindowsImage -ImagePath D:\sources\install.wim -Index 1 -Path X:\WimMount
Add-AppXProvisionedPackage -Path X:\WimMount -PackagePath X:\whatever.appx
Dismount-WindowsImage -Path X:\WimMount -Save
This is a common error that is not solved by the common solutions I have found on the internet.
Unable to run Get-PsRepository, Install-Module, and related (OneGet?) commands without them throwing the "Unable to find module providers (PowerShellGet)" error. This appears to be an issue with the NuGet packagemanager module but I do not know how to recover. The package provider installed appears valid
Symptom patterns:
C:> [Net.ServicePointManager]::SecurityProtocol
Tls12
Get-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4496 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
Register-PSRepository -Default -Verbose
VERBOSE: PowerShell meta provider initialization failed.
VERBOSE: No match was found for the specified search criteria and provider name 'PowerShellGet'. Try
'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
PackageManagement\Register-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4211 char:17
+ ... $null = PackageManagement\Register-PackageSource #PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-Pac
kageSource], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
Install-Module PowerShellGet -Force
PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Facts:
Windows 10 (1903)
Powershell 5.1.18362.1171
Running PowerShell as Administrator
Not behind a proxy
Have access to https://www.powershellgallery.com/api/v2
Have access to nuget.org
`[Net.ServicePointManager]::SecurityProtocol = Tls12
FIPS is disabled (HKLM\System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled DWORD=0)
Get-PackageProvider shows only NuGet 2.8.5.208
PowerShellGet version is 1.0.0.1 ; when trying force a sxs install with Install-Module PowerShellGet -Force I get the same: PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).
We encountered the same problem. Found this thread without a solution. But I dug a bit further and on the computer that had this problem we found version 1.4.7 of PackageManagement installed.
After removing this folder everything started working normally. I have not found how this thing got installed. Seems like a legit powershell module from Microsoft but it's interacting with the 'normal' PowershellGet module and seems to break it.
For us it was located in the %USERPROFILE%/documents/WindowsPowershell/Modules.
Also worth nothing that this %USERPROFILE% was a corporate OneDrive.
Edit: Microsoft have fixed this issue: https://github.com/PowerShell/vscode-powershell/issues/3432
Not enough Rep to comment.
I ended up in the same situation. A Windows 10 1909 machine, with
%USERPROFILE%/document being a corporate OneDrive. Moving
PackageManagement out of /WindowsPowerShell/ changed
Get-PSRepository's output from nothing to PSGallery. Thanks! – tmcg
Mar 1 at 21:35 This was exactly the same issue. I suspect this is
because PowerShell 7 dumped it into this location (possibly Visual
Studio Code when it prompt to update?) – aolszowka Mar 1 at 22:09
I encountered the same issue with packagemanagement in %USERPROFILE%/documents on my personal profile. The file dates matched when I installed VScode and the Powershell Extensions on this new machine.
Removing the folder from modules corrected the issue for the time being.
In addition to removing %USERPROFILE%/Documents/WindowsPowershell/Modules folder, I also found that putting the package manger locally helped powershell.exe -NoLogo -NoProfile -Command 'Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath ""C:\Program Files\WindowsPowerShell\Modules\""' thanks to itsho here https://github.com/PowerShell/vscode-powershell/issues/2824#issuecomment-750902181
The cause is due to the %USERPROFILE%/Documents folder being on a OneDrive and module-install keeps installing the PackageManagement module to user documents by default ignoring PSModulePath, even had the OneDrive location removed/changed.
This my module path from running PS inside vscode identifying info removed:
$env:PSModulePath -split ';'
C:\Users\{myUsername}\OneDrive - {myCompanyName}\{company}\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
There are more things that can be done to fix this from happening again discussed here https://github.com/PowerShell/PowerShell/issues/15552#issuecomment-1002708799
Like setting the documents folder to local and off OneDrive like shown here https://support.microsoft.com/en-us/topic/configuration-of-the-my-documents-folder-dfd9a90d-8f80-18d6-e7cc-f1566fc3b10b
I followed these steps for now.
In explorer to the left under quick access right click Documents, and then click Properties.
Change to the location tab in the configuration box and type the new path to the Documents folder, I used the local one
Click No so the existing files do not move and still can be accessed by going into OneDrive. I also added another quick access folder for my OneDrive location, but that is up to you.
Note: This effects other programs as well like the default save location for PowerPoint. You'll need to be mindful that you don't save something local thinking it will be backed up to OneDrive.
My module paths after the change:
$env:PSModulePath -split ';'
C:\Users\{myUsername}\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
Another workaround could be to have OneDrive keep the files local.
Navigate to %USERPROFILE%/Documents
Right click WindowsPowershell and select "Always keep on this device".
I haven't been able to test this one, but it might be the least impactful way to address this.
I am following the Chocolately Install steps (Windows 7), but have run into a couple of problems.
Firstly, I've opened Command Prompt (opening it with Run as administrator), but when trying to execute Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')), I get this error:
Uncaught SyntaxError: Unexpected identifier
..with the https: part of my command highlighted.
Further, when I try to execute Get-ExecutionPolicy, it results in:
Uncaught ReferenceError: Get is not defined
Any ideas what could be wrong?
* UPDATE *
When I try the same command in PowerShell, I get this error:
PS C:\Users\mylogin> Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtoc ol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex
((New-Object System.Net.WebClient).DownloadString
('https://chocolatey.org/install.ps1')) Exception setting
"SecurityProtocol": "Cannot convert value "3312" to type
"System.Net.SecurityProtocolType" due to inv alid enumeration values.
Specify one of the following enumeration values and try again. The
possible enumeration values are "Ssl3, Tls"." At line:1 char:85
+ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System.
Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object
System.Net.WebClient).DownloadString('https://ch
ocolatey.org/install.ps1'))
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Exception calling "DownloadString" with "1" argument(s): "The
underlying connection was closed: An unexpected error occ urred on a
send." At line:1 char:219
+ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.Se
rvicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object
System.Net.WebClient).DownloadString <<<< ('https://ch
ocolatey.org/install.ps1'))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Download chocolatey latest version from Chocolatey.org
Rename file extension to .zip
Extract the file
Open PowerShell
Open elevated PowerShell calling:
Start-Process powershell -Verb runAs
Go to the tools folder in the location where you extracted Chocolatey
Call: & .\chocolateyInstall.ps1 to allow Chocolatey to install
Add a path to the choco location to system environment PATH:
C:\ProgramData\chocolatey\bin
Restart your consoles, and VS Code (if you use one)
Chocolatey.org requires TLS 1.2 to be able to connect. This error indicates that you don't have support for that installed:
System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"
The section from the blog post I linked to earlier should help:
If you find yourself provisioning machines such as Windows 7, Windows Server 2008, or older, you will find that those machines will not be able to communicate with the Chocolatey Community Repository after we implement this change. For those instances, you will need to use alternative installation methods for Chocolatey. We strongly recommend using the offline Chocolatey installation as it provides the most flexibility and reliability.
On the Chocolatey install page the requirements are listed:
Windows 7+ / Windows Server 2003+
PowerShell v2+ (minimum is v3 for install from this website due to TLS 1.2 requirement)
.NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)(minimum is 4.5 for install from this website due to TLS 1.2 requirement)
My suggestion would be to fully patch your Windows 7 system, install .NET 4.5 and then try it. Remember Windows 7 has been out of support since January this year.
I'm trying to update a (root) certificate's friendly name through PowerShell.
The certificate I'm trying to update is highlighted in the screenshot below (taken from certmgr.msc):
Here's the PowerShell code (largely taken from here):
Set-Location cert:
cd .\CurrentUser\Root
$cert = gci .\02FAF3E291435468607857694DF5E45B68851868
$cert.FriendlyName = "UserTrust CA"
(I've verified the thumbprint with the certificate properties in certmgr.msc to make sure it's the same certificate).
The last line will result in the following error:
Exception setting "FriendlyName": "Access is denied.
"
At line:1 char:7
+ $cert. <<<< FriendlyName = "UserTrust CA"
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
I've tried the following things so far:
Running PowerShell as administrator
Changing the execution policy using: Set-ExecutionPolicy Unrestricted
Other information:
PowerShell version is 2.0 (running on Windows 7 Enterprise x64)
I'm running the x64 version of PS
DEP and UAC are disabled
My account is part of the Administrators group
I'm a complete PowerShell n00b ;-)
PS version output:
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1
You need to update your version of Powershell to 3.0 or 4.0.
See Get-ChildItem for Certificate
I have Powershell 4.0 and I was able to change the FriendlyName without problems. This was visible in certmgr.msc after a restart.
You can download Powershell 4.0 here.
If you are a Powershell beginner it's probably better to use Get-ChildItem instead of gci for improved readability. Also, cd is an alias of Set-Location so it's better to choose one or the other in your script to avoid confusion.
Description: I am running/executing powershell from a ruby script (.rb) file
exec "powershell.exe Import-Module PSWindowsUpdate"
I downloaded the PSWindowsUpdate module from "Windows Update PowerShell Module" and copied the files to the following location:
%WINDIR%\System32\WindowsPowerShell\v1.0\Modules
When I run the above I get the following error:
Z:\Desktop>ruby windows_patch.rb
Import-Module : The specified module 'PSWindowsUpdate' was not loaded because
no valid module file was found in any module directory.At line:1 char:1
+ Import-Module PSWindowsUpdate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (PSWindowsUpdate:String) [I
mport-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
ands.ImportModuleCommand
However, when I run this via Powershell it runs fine and dandy.
I'm using:
Windows 7 x64
PowerShell v4
Ruby v2.1.5
The result of exec "powershell.exe ruby -e 'puts $:'" is:
C:/Ruby21/lib/ruby/site_ruby/2.1.0
C:/Ruby21/lib/ruby/site_ruby/2.1.0/i386-msvcrt
C:/Ruby21/lib/ruby/site_ruby
C:/Ruby21/lib/ruby/vendor_ruby/2.1.0
C:/Ruby21/lib/ruby/vendor_ruby/2.1.0/i386-msvcrt
C:/Ruby21/lib/ruby/vendor_ruby
C:/Ruby21/lib/ruby/2.1.0
C:/Ruby21/lib/ruby/2.1.0/i386-mingw32
I ran powershell.exe $env:PSModulePath which gave me:
\vmware-host\Shared Folders\Documents\WindowsPowerShell\Modules;C:\Program Files (x86)\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\M
odules\
I then copied the folder to C:\Program Files (x86)\WindowsPowerShell\Modules
I then got:
Import-Module : The specified module 'PSWindowsUpdate' was not loaded because
no valid module file was found in any module directory.At line:1 char:39
Next, I then ran:
PS C:\Users\Justin.Schuhmann> Set-ExecutionPolicy -Scope LocalMachine
cmdlet Set-ExecutionPolicy at command pipeline position 1
Supply values for the following parameters:
ExecutionPolicy: Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
This solved the issue, I don't have a permanent solution yet as this is only temporary. When setting