I’m in need of a sanity check. I’ve got several scripts that run that process terminated/inactive users in our environment. I’ve been using this same chunk of code for months.
#Credential setup for O365
Import-Module MSOnlineExtended
$O365User = “user@domain.com”
$O365Pass = “pass” | ConvertTo-SecureString -AsPlainText -Force
$O365Creds = New-Object System.Management.Automation.PSCredential ($O365User, $O365Pass)
Function Connect-O365
{
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $O365Creds -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber
Import-Module Msonline
Connect-MSOLService -credential $O365Creds
}
Import-Module ActiveDirectory
Connect-O365
but as of some point yesterday I’m getting this error.
Connect-MSOLService : Could not load file or assembly ‘Microsoft.Online.Administration.Automation.PSModule.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
or one of its dependencies. The system cannot find the file specified.
At line:12 char:2
-
Connect-MSOLService -credential $O365Creds
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (Microsoft.Onlin…nectMsolService:ConnectMsolService) [Connect-MsolService], FileNotFoundException
- FullyQualifiedErrorId : System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Online.Administration.Automation.PSModule.Resources, Version=1.0.0.0, Culture=n
eutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.
File name: ‘Microsoft.Online.Administration.Automation.PSModule.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
at Microsoft.Online.Administration.Automation.ConnectMsolService.MsolCmdletProcessRecord()
at Microsoft.Online.Administration.Automation.MsolCmdlet.ProcessRecord()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
,Microsoft.Online.Administration.Automation.ConnectMsolService
Connect-MSOLService : Could not load file or assembly ‘Microsoft.Online.Administration.Automation.PSModule.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
or one of its dependencies. The system cannot find the file specified.
At line:12 char:2
-
Connect-MSOLService -credential $O365Creds
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: ( [Connect-MsolService], FileNotFoundException
- FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Online.Administration.Automation.ConnectMsolService
This happens across multiple machines and multiple different accounts. Any help or recommendations would be greatly appreciated.