{"id":686,"date":"2023-06-30T14:23:26","date_gmt":"2023-06-30T05:23:26","guid":{"rendered":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=686"},"modified":"2023-07-04T10:06:21","modified_gmt":"2023-07-04T01:06:21","slug":"ms-graph%e3%81%a7%e3%83%86%e3%83%8a%e3%83%b3%e3%83%88%e3%81%ae%e3%83%a9%e3%82%a4%e3%82%bb%e3%83%b3%e3%82%b9%e3%82%92%e5%8f%96%e5%be%97","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=686","title":{"rendered":"MS Graph\u3067\u30c6\u30ca\u30f3\u30c8\u306e\u30e9\u30a4\u30bb\u30f3\u30b9\u3092\u53d6\u5f97"},"content":{"rendered":"\n<p>Powershell Office365\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u306f\u3001\u7c21\u5358\u306b\u30c6\u30ca\u30f3\u30c8\u306e\u30e9\u30a4\u30bb\u30f3\u30b9\u60c5\u5831\u3092\u53d6\u5f97\u3067\u304d\u308b\u306e\u3060\u304c\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089MS Graph\u3067\u53d6\u5f97\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u304b\u3001\u8abf\u3079\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>\u8abf\u3079\u65b9\u304c\u60aa\u3044\u306e\u304b\u3001\u3042\u307e\u308a\u4f8b\u304c\u30d2\u30c3\u30c8\u3057\u306a\u304b\u3063\u305f\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u53d6\u5f97\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u3001Azure AD\u4e0a\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5fc5\u8981\u306a\u3001\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Origanization.Read.All<\/li>\n\n\n\n<li>Directory.ReadAll<\/li>\n\n\n\n<li>Organization.ReadWrite.All<\/li>\n\n\n\n<li>Directory.ReadWrite.ALl<\/li>\n<\/ul>\n\n\n\n<p>\u306a\u305c\u3001Write\u304c\u5fc5\u8981\u306a\u306e\u304b\u306f\u4e0d\u660e\u30fb\u30fb\u30fb<\/p>\n\n\n\n<p>\u53d6\u5f97\u65b9\u6cd5\u3060\u304c\u3001Graph\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306eServiceClient\u3092\u4f5c\u6210\u3057\u3066\u3001.SubscribedSkus.GetAsync()\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3060\u3051\u3002<\/p>\n\n\n\n<p>\u623b\u308a\u5024\u3068\u3057\u3066\u3001\u5951\u7d04\u3057\u3066\u3044\u308b\u30e9\u30a4\u30bb\u30f3\u30b9\u60c5\u5831\u4e00\u89a7\u304c\u8fd4\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e9\u30a4\u30bb\u30f3\u30b9\u60c5\u5831\u306e\u53d6\u5f97\" data-lang=\"C#\"><code>\/\/ GraphServiceClient\u306e\u4f5c\u6210(Credential\u306e\u4f5c\u6210\u65b9\u6cd5\u306f\u7701\u7565)\nvar cli = new GraphServiceClient(cred);\n\/\/ \u5951\u7d04\u3057\u3066\u3044\u308b\u30e9\u30a4\u30bb\u30f3\u30b9\u60c5\u5831\u4e00\u89a7\u306e\u53d6\u5f97\nvar lic = await cli.SubscribedSkus.GetAsync();<\/code><\/pre><\/div>\n\n\n\n<p>\u4e0a\u8a18\u306e\u5834\u5408\u3001lic.Value\u306bList&lt;SubscribedSku&gt;?\u304c\u5165\u3063\u3066\u304f\u308b\u3002SubscribedSku\u306b\u306f\u69d8\u3005\u306a\u60c5\u5831\u304c\u5165\u3063\u3066\u304f\u308b\u304c\u3001\u7279\u306b\u3088\u304f\u4f7f\u3046\u306e\u306f\u4e0b\u8a18\u3050\u3089\u3044\u3060\u3068\u601d\u308f\u308c\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SkuPartNumber<\/td><td>\u30e9\u30a4\u30bb\u30f3\u30b9\u540d<\/td><td>ENTERPRISEPACK\u306e\u3088\u3046\u306a\u8868\u8a18<\/td><\/tr><tr><td>ConsumedUnits<\/td><td>\u4f7f\u7528\u30e9\u30a4\u30bb\u30f3\u30b9\u6570<\/td><td><\/td><\/tr><tr><td>PrepaidUnits.Enabled<\/td><td>\u8cfc\u5165\u6570<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">\u4e3b\u306a\u30d7\u30ed\u30d1\u30c6\u30a3<\/figcaption><\/figure>\n\n\n\n<p>\u3053\u306e\u60c5\u5831\u304c\u53d6\u308c\u308c\u3070\u3001\u3069\u306e\u30e9\u30a4\u30bb\u30f3\u30b9\u3092\u4f55\u30e9\u30a4\u30bb\u30f3\u30b9\u5951\u7d04\u3057\u3066\u3044\u3066\u3001\u4f7f\u7528\u6570\u304c\u4f55\u30e9\u30a4\u30bb\u30f3\u30b9\u304b\u5206\u304b\u308a\u3001\u8a08\u7b97\u3059\u308c\u3070\u5272\u5f53\u53ef\u80fd\u6570\u3082\u53d6\u5f97\u3067\u304d\u308b\u306e\u3067\u3001\u7d50\u69cb\u4fbf\u5229\u3002<\/p>\n\n\n\n<p>\u203bSkuPartNumber\u306f<a rel=\"noreferrer noopener\" href=\"https:\/\/learn.microsoft.com\/ja-jp\/azure\/active-directory\/enterprise-users\/licensing-service-plan-reference\" target=\"_blank\">\u3053\u3053<\/a>\u306b\u4e00\u89a7\u304c\u3042\u308b\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u5b9f\u884c\u4f8b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u5b9f\u884c\u4f8b\" data-lang=\"C#\"><code>GraphServiceClient cli = new GraphServiceClient(cred);\nvar lic = await cli.SubscribedSkus.GetAsync();\nif (lic == null) {\n    Console.WriteLine(&quot;Get License Fail&quot;);\n    return;\n}\nif (lic.Value == null) {\n    Console.WriteLine(&quot;Get License Fail&quot;);\n    return;\n}\nforeach(var itm in lic.Value) {\n    int all = (int)itm.PrepaidUnits.Enabled!;\n    int use = (int)itm.ConsumedUnits!;\n    Console.WriteLine($&quot;{itm.SkuPartNumber},{all},{use},{all-use}&quot;);\n}\n\/* \u5b9f\u884c\u4f8b\nSTREAM,XXXX,YY,MMMM\nDynamics_365_Sales_Premium_Viral_Trial,XXXX,YY,ZZZZ\nWINDOWS_STORE,XXXX,Y,ZZZZ\nENTERPRISEPACK,XX,YY,ZZ\nFLOW_FREE,XXXX,YY,ZZZZ\nMICROSOFT_BUSINESS_CENTER,XXXX,Y,ZZZZ\nPOWERAPPS_VIRAL,XXXX,Y,ZZZZ\nEXCHANGESTANDARD,XXX,YY,ZZ\nPOWER_BI_STANDARD,XXXX,Y,ZZZZ\nOFFICESUBSCRIPTION,XXX,YYY,ZZ\nPower_Pages_vTrial_for_Makers,XXXX,Y,ZZZZ\nSTANDARDPACK,XXX,YYY,ZZ\n*\/<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Powershell Office365\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u306f\u3001\u7c21\u5358\u306b\u30c6\u30ca\u30f3\u30c8\u306e\u30e9\u30a4\u30bb\u30f3 &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=686\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,9,16,4],"tags":[],"class_list":["post-686","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-microsoft-graph","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=686"}],"version-history":[{"count":4,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/686\/revisions"}],"predecessor-version":[{"id":690,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/686\/revisions\/690"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}