rodneyviana / ODSyncService

OneDrive service/DLL for Sync State
MIT License
93 stars 26 forks source link

Cannot import module without creating a manifest #5

Closed mmtechnodrone closed 4 years ago

mmtechnodrone commented 5 years ago

import-module OneDriveLib.dll fails with "Could no load file or assembly.... expected to contain a manifest. If I create a OneDriveLib.psd1 containing

@{

ModuleVersion="1.0"
CmdletsToExport = @()
VariablesToExport = '*'
AliasesToExport = @()

}

I can import the module but Get-ODStatus is not available and get-module -ListAvailable returns no cmdlets. I have gotten it to report by change @() to Get-ODStatus but running the command still returns "not recognized as the name of a cmdlet, function," ......

rodneyviana commented 5 years ago

Hi mmayfield1,

When you download an unsigned DLL from the Internet as it is the case, the module is blocked by the operating system. You need to right-click the module and check ‘Unblock’ or run the command:

Unblock-File -Path

Let me know if it resolved the issue.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: mmayfield1 notifications@github.com Sent: Friday, May 17, 2019 12:21:27 PM To: rodneyviana/ODSyncService Cc: Subscribed Subject: [rodneyviana/ODSyncService] Cannot import module without creating a manifest (#5)

import-module OneDriveLib.dll fails with "Could no load file or assembly.... expected to contain a manifest. If I create a OneDriveLib.psd1 containing

@{

ModuleVersion="1.0" CmdletsToExport = @() VariablesToExport = '*' AliasesToExport = @()

}

I can import the module but Get-ODStatus is not available and get-module -ListAvailable returns no cmdlets. I have gotten it to report by change @() to Get-ODStatus but running the command still returns "not recognized as the name of a cmdlet, function," ......

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frodneyviana%2FODSyncService%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAGT5MATDHRTLNYRS5VEJDWLPV3SRPA5CNFSM4HNXBLVKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUONNSQ&data=02%7C01%7C%7C09acb4dd00bb4fb2e23208d6daec18b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636937104890845331&sdata=QbzutTpgmqGlSycOOJPqeyWCt%2Brj5RWTC19bFWzi%2BYA%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGT5MAQFCVCAHCS3RACLZJ3PV3SRPANCNFSM4HNXBLVA&data=02%7C01%7C%7C09acb4dd00bb4fb2e23208d6daec18b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636937104890855342&sdata=URXoZvTVBP%2FS6%2FT7N3O1Bx6awJE0ezwA%2B1Fhx2PS3fE%3D&reserved=0.

mmtechnodrone commented 5 years ago

Unblocking the file was one of the first things I tried.

mmtechnodrone commented 5 years ago

OneDriveLibError

rodneyviana commented 5 years ago

Hi mmayfield,

Drop the .psd1

Run: Unblock-File -Path .\OneDriveLib.dll # I know you did it, but just for good measure Import-Module .\OneDriveLib.dll Get-ODStatus

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: mmayfield1 notifications@github.com Sent: Monday, May 20, 2019 10:12:20 AM To: rodneyviana/ODSyncService Cc: Rodney Viana; Comment Subject: Re: [rodneyviana/ODSyncService] Cannot import module without creating a manifest (#5)

[OneDriveLibError]https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F12780846%2F58032186-b2f5d480-7ae7-11e9-8827-731afc154aca.PNG&data=02%7C01%7C%7C5e0ad17f8c9b40d0b31508d6dd358eb0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939619421336702&sdata=dogR7ZiCnBJIhs589mgVU8FGJusHXKy3XwqzOLYRCsA%3D&reserved=0

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frodneyviana%2FODSyncService%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAGT5MAXSB2LH2HQ72BFYZS3PWK5VJA5CNFSM4HNXBLVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVZEUZY%23issuecomment-494029415&data=02%7C01%7C%7C5e0ad17f8c9b40d0b31508d6dd358eb0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939619421346707&sdata=d7p%2F8t6vynOe92HwWjHLy0bEnuQxOCjE76gFUq4eD4k%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGT5MAUSESFCMZJVUSNMOZDPWK5VJANCNFSM4HNXBLVA&data=02%7C01%7C%7C5e0ad17f8c9b40d0b31508d6dd358eb0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939619421356718&sdata=K07BWaqe%2F4CulOhhKnNjzNZC0haNRnjZhiDvslffSgk%3D&reserved=0.

mmtechnodrone commented 5 years ago

Capture

As I said, I can't even import the module without the psd1 (manifest) file

rodneyviana commented 5 years ago

This image is corrupted (bad image). Run Get-FileHash to check the signature. Next time I login I will check the official hash and post again. Meanwhile you may want to try to download it again.

Get Outlook for iOShttps://aka.ms/o0ukef


From: mmayfield1 notifications@github.com Sent: Monday, May 20, 2019 6:08:18 PM To: rodneyviana/ODSyncService Cc: Rodney Viana; Comment Subject: Re: [rodneyviana/ODSyncService] Cannot import module without creating a manifest (#5)

[Capture]https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F12780846%2F58054882-a8f0c780-7b21-11e9-9092-a0ed69202cdc.PNG&data=02%7C01%7C%7C0a101b17af3140c0f1ec08d6dd6faa24%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939868989682774&sdata=X1351hFlpYJ%2FVH%2BCBjWRPETFSEwA4a1%2Bqk5bTdLEOMY%3D&reserved=0

As I said, I can't even import the module with the psd1 (manifest) file

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frodneyviana%2FODSyncService%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAGT5MAVKPNUY44UHJOAO6V3PWMONFA5CNFSM4HNXBLVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV2GSCI%23issuecomment-494168329&data=02%7C01%7C%7C0a101b17af3140c0f1ec08d6dd6faa24%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939868989702802&sdata=91qZulrVAGtAkNvhadyI%2F9YBbM9ek79uHToAV4NyJ%2FU%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGT5MAXEPB3L4K5E3X2FNJLPWMONFANCNFSM4HNXBLVA&data=02%7C01%7C%7C0a101b17af3140c0f1ec08d6dd6faa24%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636939868989712807&sdata=6Dlo5LEw5z6BJXMWPzbo80PYSky0LPyfHLFJ7%2FYMOto%3D&reserved=0.

rodneyviana commented 5 years ago

Hi mmayField1,

I believe I know why you are having the problem. The DLL was compiled to .NET 3.5 which is not installed by default on Windows 10. This may be the cause of the bad image. I recompiled to 4.5 and uploaded here: https://github.com/rodneyviana/ODSyncService/tree/master/Binaries/PowerShell

See if it works now.

mmtechnodrone commented 5 years ago

Hi mmayField1,

I believe I know why you are having the problem. The DLL was compiled to .NET 3.5 which is not installed by default on Windows 10. This may be the cause of the bad image. I recompiled to 4.5 and uploaded here: https://github.com/rodneyviana/ODSyncService/tree/master/Binaries/PowerShell

See if it works now.

I'll give it a shot. Pretty sure our Win 10 images have .net 3.5 in the image.

mmtechnodrone commented 5 years ago

Same behavior.

mmtechnodrone commented 5 years ago

The filehash I get for the 4.5 version is SHA256 FB61368E775BDB2BC09795F640D0E99DE36C614C709D68320A2E40D2BBAAC228

rodneyviana commented 5 years ago

I got a different reading:

PS C:\temp> Get-FileHash .\OneDriveLib.dll

Algorithm Hash Path


SHA256 F22F235E496F7335CCFB93BF51F25CFA2F6B0532E45EE2B1E72BCCAF6904DFA2 C:\temp\OneDriveLib.dll

And I downloaded again to make sure it is what I uploaded. The same result. This code reading directly from web also gave the same result:

$url = 'https://github.com/rodneyviana/ODSyncService/raw/master/Binaries/PowerShell/OneDriveLib.dll'; $Response = Invoke-WebRequest -Uri $url $Stream = $Response.RawContentStream; Get-FileHash -InputStream $Stream

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: mmayfield1 notifications@github.com Sent: Wednesday, May 22, 2019 12:59:58 PM To: rodneyviana/ODSyncService Cc: Rodney Viana; Comment Subject: Re: [rodneyviana/ODSyncService] Cannot import module without creating a manifest (#5)

The filehash I get for the 4.5 version is SHA256 FB61368E775BDB2BC09795F640D0E99DE36C614C709D68320A2E40D2BBAAC228

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frodneyviana%2FODSyncService%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAGT5MASNVSYNUSEU6PDJDTTPWV3Y5A5CNFSM4HNXBLVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV7V3MY%23issuecomment-494886323&data=02%7C01%7C%7C8ce3c22581fe41b4aeec08d6ded6eca5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636941411999297756&sdata=Tz%2BLVdrNW8o9ethUHFRmXDZnAi5WB0ivNCtfx%2BxgX74%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGT5MAQ6GJJR7VYVVH7V6FDPWV3Y5ANCNFSM4HNXBLVA&data=02%7C01%7C%7C8ce3c22581fe41b4aeec08d6ded6eca5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636941411999307773&sdata=mqnXEIYRlef%2B706GKBwtAPf3VjkyWs1fPuVeAtG1GXE%3D&reserved=0.

mmtechnodrone commented 5 years ago

So it must have been one of the security applications on my Windows box. I downloaded it from my Linux box and transferred it over. The download on the Linux box matched your filehash and powershell was able to load it without a manifest and get-odstatus worked. Thank you! Sorry for taking your time.

bigsby-exe commented 4 years ago

Weirdly getting the same issue, but tried on a Linux and Windows machine, getting a different file hash all together: 31CEFDC5B28E6C3A8701444ACD0C2C5981D405034024DD600DB751E69B3C13BF

rodneyviana commented 4 years ago

Weirdly getting the same issue, but tried on a Linux and Windows machine, getting a different file hash all together: 31CEFDC5B28E6C3A8701444ACD0C2C5981D405034024DD600DB751E69B3C13BF

It will change with each new version. To check the current version, run this powershell script:

$url = 'https://github.com/rodneyviana/ODSyncService/raw/master/Binaries/PowerShell/OneDriveLib.dll';
$Response = Invoke-WebRequest -Uri $url
$Stream = $Response.RawContentStream;
Get-FileHash -InputStream $Stream

As of Jan 10, 2020, the value was:

Algorithm       Hash                                                                   Path                     
---------       ----                                                                   ----                     
SHA256          31CEFDC5B28E6C3A8701444ACD0C2C5981D405034024DD600DB751E69B3C13BF                                

Which matches yours. So, what is the problem you are seeing?

bigsby-exe commented 4 years ago

This works on my work machine but not on my home machine, must be something to do with my execution policy.

Thanks for the reply, this can be re-closed as it all works.