microsoftgraph / powershell-intune-samples

This repository of PowerShell sample scripts show how to access Intune service resources. They demonstrate this by making HTTPS RESTful API requests to the Microsoft Graph API from PowerShell.
MIT License
1.36k stars 654 forks source link

Json import script errors #111

Closed Sittampalam closed 5 years ago

Sittampalam commented 5 years ago

Hello When I try to run the json import script DeviceConfiguration_Import_FromJSON I get a series of errors about charcter not supported etc.. and the script does not run. Does it require a particular version of PS? the instruction sgiven does not specify much apart from the path where the json files are. PS C:\source\intune\win10_1703_mdm_configuration\NCSC - Windows 10 - MDM Configuration> .\DeviceConfiguration_Import_Fro mJSON.ps1

Security warning Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning message. Do you want to run C:\source\intune\win10_1703_mdm_configuration\NCSC - Windows 10 - MDM Configuration\DeviceConfiguration_Import_FromJSON.ps1? [D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): R At C:\source\intune\win10_1703_mdm_configuration\NCSC - Windows 10 - MDM Configuration\DeviceConfiguration_Import_FromJSON.ps1:312 char:159

PS C:\source\intune\win10_1703_mdm_configuration\NCSC - Windows 10 - MDM Configuration>

davefalkus commented 5 years ago

I've tested the script on github and it worked as expected: https://github.com/microsoftgraph/powershell-intune-samples/blob/master/DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1

How did you download the script? Did you copy the "raw" version from the website?

Sittampalam commented 5 years ago

Hello Dave

I right clicked on the file and then save link which save the file to my local drive. Is there a zipped file with all the scripts that I can download please?

Nagu Sittampalam Security Team Leader Digital and Strategic IT Southampton City Council Landline: 02380 833012 | Fax: 02380 832973 e-mail Nagu.Sittampalam@southampton.gov.ukmailto:Nagu.Sittampalam@southampton.gov.uk post Southampton City Council, IT services, 1st Floor, One Guildhall Square, Above Bar, Southampton, SO14 7FP

From: davefalkus notifications@github.com Sent: 01 August 2019 13:01 To: microsoftgraph/powershell-intune-samples powershell-intune-samples@noreply.github.com Cc: Sittampalam, Nagu Nagu.Sittampalam@southampton.gov.uk; Author author@noreply.github.com Subject: Re: [microsoftgraph/powershell-intune-samples] Json import script errors (#111)

CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe.

I've tested the script on github and it worked as expected: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoftgraph_powershell-2Dintune-2Dsamples_blob_master_DeviceConfiguration_DeviceConfiguration-5FImport-5FFromJSON.ps1&d=DwIGaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4iIKMQDMi20CHqEeEJ9anCVoJetNXBsESKlUlARLX0kdvX4566TxwT3UaxV1rPZz_OWrFXyIcDlfUf8rncgfv3TgQLiX0HPATQIu8Hq34VQ&m=2vUO2rZvIk00gxPwecErvdq-qhWqcdcK3Z5mjGaYOr4&s=riGEN9lRAuQglJd56Cbhmjk7XJHxpSzGpXqyGmK9kPQ&e= https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoftgraph_powershell-2Dintune-2Dsamples_blob_master_DeviceConfiguration_DeviceConfiguration-5FImport-5FFromJSON.ps1&d=DwMCaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4p-MSbeWAaQcZNJMtmLSBa9h2Ajy2ASmEpj7Q6n123Sdxlzi_0WQoss7_UYIHnEk&m=C6vUFHBjuy1pflEDbb89DyalacNQNqukDYrFfK3mESM&s=uvG8wQX_gL7KaBZtNoDvCcsbv-H_VQQN_7u5VlQVSdM&e=

How did you download the script? Did you copy the "raw" version from the website?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoftgraph_powershell-2Dintune-2Dsamples_issues_111-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAL27MWM4E474P25QNAU7PHDQCLGBTA5CNFSM4IIN5P6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3KLDOA-23issuecomment-2D517255608&d=DwMCaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4p-MSbeWAaQcZNJMtmLSBa9h2Ajy2ASmEpj7Q6n123Sdxlzi_0WQoss7_UYIHnEk&m=C6vUFHBjuy1pflEDbb89DyalacNQNqukDYrFfK3mESM&s=PM-_IJk8bxy3PnUpDxzWNXUsJBjAR-CroPR1qGun9CM&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AL27MWOKMMRQOWVMZE6CWKTQCLGBTANCNFSM4IIN5P6A&d=DwMCaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4p-MSbeWAaQcZNJMtmLSBa9h2Ajy2ASmEpj7Q6n123Sdxlzi_0WQoss7_UYIHnEk&m=C6vUFHBjuy1pflEDbb89DyalacNQNqukDYrFfK3mESM&s=fVvT6qRsJ8VTnw3G-obYBJzVPvRRTmIRcAz3vNcB-7w&e=.

This email is confidential but may have to be disclosed under the Freedom of Information Act 2000, Environmental Information Regulations 2004 or data protection legislation. If you are not the person or organisation it was meant for, apologies, please ignore it, delete it, and notify us. SCC does not make legally binding agreements or accept formal notices/proceedings by email. E-mails may be monitored. This email (and its attachments) is intended only for the use of the person(s) to whom it is addressed, and may contain information that is privileged and/or confidential. If it has come to you in error, you must take no action based on it, nor must you copy or show it to anyone.

Sittampalam commented 5 years ago

OK I have clicked on raw and then cut and pasted into notepad snd noe the script ran. I still get an error but I suspect it is syntax. The file path it is asking should also include the file name as well? I thought it will look in directory and import all the json files there. What are the created policies called in Intune? I assume it i snot going to interfear with any existing policies and also it is not going to apply to any devices or users?

davefalkus commented 5 years ago

The script references using the entire path to a single JSON file: Please specify a path to a JSON file to import data from e.g. C:\IntuneOutput\Policies\policy.json:

The policies created will be the name from the exported JSON file, you can change the name in the JSON file before importing.

Sittampalam commented 5 years ago

Thank you very much for your help. I have imported all the policies now.

Nagu Sittampalam Security Team Leader Digital and Strategic IT Southampton City Council Landline: 02380 833012 | Fax: 02380 832973 e-mail Nagu.Sittampalam@southampton.gov.ukmailto:Nagu.Sittampalam@southampton.gov.uk post Southampton City Council, IT services, 1st Floor, One Guildhall Square, Above Bar, Southampton, SO14 7FP

From: davefalkus notifications@github.com Sent: 01 August 2019 14:23 To: microsoftgraph/powershell-intune-samples powershell-intune-samples@noreply.github.com Cc: Sittampalam, Nagu Nagu.Sittampalam@southampton.gov.uk; Author author@noreply.github.com Subject: Re: [microsoftgraph/powershell-intune-samples] Json import script errors (#111)

CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe.

The script references using the entire path to a single JSON file: Please specify a path to a JSON file to import data from e.g. C:\IntuneOutput\Policies\policy.json:

The policies created will be the name from the exported JSON file, you can change the name in the JSON file before importing.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoftgraph_powershell-2Dintune-2Dsamples_issues_111-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAL27MWOSAA4WWIAU75C2PGTQCLPT7A5CNFSM4IIN5P6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3KSQYI-23issuecomment-2D517285985&d=DwMCaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4p-MSbeWAaQcZNJMtmLSBa9h2Ajy2ASmEpj7Q6n123Sdxlzi_0WQoss7_UYIHnEk&m=5IunCG4tNQtYFKw2tRYRfEJKqe9mX87PPEaphxdD3xY&s=DiU1ZVYg5XL0SBeIDMDeZrKKUoJj3AVlcUMPM9NdFCQ&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AL27MWJ5Y2RZM7ZYUXAPQK3QCLPT7ANCNFSM4IIN5P6A&d=DwMCaQ&c=pbUzoxRZCRvayVvkYvkiMO6u1jPMdBrTZxWyx_2PsKs&r=4p-MSbeWAaQcZNJMtmLSBa9h2Ajy2ASmEpj7Q6n123Sdxlzi_0WQoss7_UYIHnEk&m=5IunCG4tNQtYFKw2tRYRfEJKqe9mX87PPEaphxdD3xY&s=CwNt7RitFt130Lta1AYO7sY5D4aVsntKZnlUi0z-Bcw&e=.

This email is confidential but may have to be disclosed under the Freedom of Information Act 2000, Environmental Information Regulations 2004 or data protection legislation. If you are not the person or organisation it was meant for, apologies, please ignore it, delete it, and notify us. SCC does not make legally binding agreements or accept formal notices/proceedings by email. E-mails may be monitored. This email (and its attachments) is intended only for the use of the person(s) to whom it is addressed, and may contain information that is privileged and/or confidential. If it has come to you in error, you must take no action based on it, nor must you copy or show it to anyone.

davefalkus commented 5 years ago

Thanks for the update, will close the issue