{"id":423,"date":"2023-05-14T17:29:39","date_gmt":"2023-05-14T15:29:39","guid":{"rendered":"https:\/\/nicolasheudron.com\/?p=423"},"modified":"2023-05-31T09:48:17","modified_gmt":"2023-05-31T07:48:17","slug":"utiliser-nano-et-sudo-sur-powershell","status":"publish","type":"post","link":"https:\/\/nicolasheudron.com\/index.php\/utiliser-nano-et-sudo-sur-powershell\/2023\/05\/","title":{"rendered":"Utiliser nano et sudo sur powershell"},"content":{"rendered":"\n<p>J\u2019utilise r\u00e9guli\u00e8rement PowerShell pour piloter d\u2019autres machines en SSH. C\u2019est un outil que j\u2019appr\u00e9cie de plus en plus car je trouve qu\u2019il tend \u00e0 devenir aussi flexible que Bash.<\/p>\n\n\n\n<p>En utilisant Bash, j\u2019ai l\u2019habitude de ne jamais utiliser les interfaces graphiques de Linux, qui ne sont m\u00eame pas install\u00e9es sur mes machines d\u2019ailleurs. C\u2019est pour cette raison que j\u2019ai rapidement eu besoin d\u2019utiliser PowerShell sans passer par les logiciels graphiques de Windows (Bloc-notes).<\/p>\n\n\n\n<p>Le bloc-notes est un petit outil bien pratique, mais nano n\u2019est d\u2019autant plus que nous n\u2019avons pas besoin de quitter notre console PowerShell.<\/p>\n\n\n\n<p>Nous allons donc voir comment installer nano sur powershell en quelques commandes.<\/p>\n\n\n\n<p>Commen\u00e7ons par lancer le Terminal avec les droits administrateurs (depuis le menu d\u00e9marrer, clic droit &gt; Ex\u00e9cuter en tant qu\u2019administrateur)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"378\" src=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/powershell.jpg\" alt=\"\" class=\"wp-image-424\" srcset=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/powershell.jpg 575w, https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/powershell-300x197.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" style=\"font-size:.875rem;--cbp-line-number-color:#d8dee9ff;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https:\/\/chocolatey.org\/install.ps1'))\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #88C0D0\">Set-ExecutionPolicy<\/span><span style=\"color: #D8DEE9FF\"> Bypass <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\">Scope <\/span><span style=\"color: #81A1C1\">Process<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\">Force<\/span><span style=\"color: #81A1C1\">;<\/span><span style=\"color: #D8DEE9FF\"> iex <\/span><span style=\"color: #ECEFF4\">((<\/span><span style=\"color: #88C0D0\">New-Object<\/span><span style=\"color: #D8DEE9FF\"> System.Net.WebClient<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\">.DownloadString<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">https:\/\/chocolatey.org\/install.ps1<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">))<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#2e3440ff;color:#c8d0e0;font-size:12px;line-height:1;position:relative\">PowerShell<\/span><\/div>\n\n\n\n<p>Nous installons ici un gestionnaire de paquets nomm\u00e9 Chocolatey. C\u2019est un \u00e9quivalent de apt sur Windows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"371\" src=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/setexecution.jpg\" alt=\"\" class=\"wp-image-425\" srcset=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/setexecution.jpg 575w, https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/setexecution-300x194.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<p>Il est conseill\u00e9, apr\u00e8s l&rsquo;ex\u00e9cution de cette commande, de fermer le terminal et de le r\u00e9ouvrir \u2026 on est toujours sur Windows, pas de miracle.<\/p>\n\n\n\n<p>En r\u00e9ouvrant le Terminal avec les droits administrateurs, nous pouvons maintenant effectuer la commande suivante :<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" style=\"font-size:.875rem;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:8px;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"choco install nano\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">choco install nano<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#2e3440ff;color:#c8d0e0;font-size:12px;line-height:1;position:relative\">PowerShell<\/span><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"167\" src=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/chocoinstall.jpg\" alt=\"\" class=\"wp-image-426\" srcset=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/chocoinstall.jpg 575w, https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/chocoinstall-300x87.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<p>Et c\u2019est parti, vous pouvez utiliser nano tout comme avec Bash.<\/p>\n\n\n\n<p>Pour la modification de fichiers n\u00e9cessitant les droits administrateurs, il serait tr\u00e8s pratique d\u2019\u00e9viter d\u2019avoir \u00e0 fermer et r\u00e9-ouvrir le terminal.<\/p>\n\n\n\n<p>Sachez qu\u2019il est possible d\u2019avoir sudo !<\/p>\n\n\n\n<p>Pour cela, rien de plus simple :<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" style=\"font-size:.875rem;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:8px;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"choco install sudo\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">choco install sudo<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#2e3440ff;color:#c8d0e0;font-size:12px;line-height:1;position:relative\">PowerShell<\/span><\/div>\n\n\n\n<p>Et le tour est jou\u00e9.<\/p>\n\n\n\n<p>Vous pouvez essayer la commande en installant le petit paquet tree, qui permet de visualiser un dossier sous forme d\u2019arborescence. Plus besoin de fermer et ouvrir le terminal avec les droits je ne sais quoi. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" style=\"font-size:.875rem;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:8px;line-height:1.25rem\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"sudo choco install tree\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">sudo choco install tree<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#2e3440ff;color:#c8d0e0;font-size:12px;line-height:1;position:relative\">PowerShell<\/span><\/div>\n\n\n\n<p>Et vous pouvez utiliser tree en utilisant la simple commande : <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"409\" src=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/tree.jpg\" alt=\"\" class=\"wp-image-427\" srcset=\"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/tree.jpg 575w, https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/tree-300x213.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<p>Merci d&rsquo;avoir lu cet article. Retrouvez en d&rsquo;autres sur le blog !<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>J\u2019utilise r\u00e9guli\u00e8rement PowerShell pour piloter d\u2019autres machines en SSH. C\u2019est un outil que j\u2019appr\u00e9cie de [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":424,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-423","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/nicolasheudron.com\/wp-content\/uploads\/2023\/05\/powershell.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/posts\/423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":2,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/posts\/423\/revisions"}],"predecessor-version":[{"id":482,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/posts\/423\/revisions\/482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/media\/424"}],"wp:attachment":[{"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/categories?post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicolasheudron.com\/index.php\/wp-json\/wp\/v2\/tags?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}