Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment activer Cloud Tools for PowerShell, s'authentifier avec la gcloud CLI et exécuter les cmdlets PowerShell.
Avant de commencer
Procédez comme suit :
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Installez la gcloud CLI à partir de la ligne de commande PowerShell en exécutant la commande suivante en tant qu'administrateur :
Install-Module GoogleCloud
S'authentifier avec gcloud CLI
Cloud Tools for PowerShell utilise vos identifiants et paramètres stockés dans gcloud CLI pour activer les cmdlets. Pour utiliser les cmdlets, connectez-vous d'abord à l'aide de la gcloud CLI :
Dans l'invite de commande, exécutez la commande suivante :
gcloud init
Acceptez l'option de connexion avec votre compte utilisateur Google :
To continue, you must log in. Would you like to log in (Y/n)? Y
Dans votre navigateur, connectez-vous à votre compte utilisateur Google lorsque vous y êtes invité, puis cliquez sur Autoriser pour autoriser l'accès aux ressources Google Cloud .
Dans l'invite de commande, sélectionnez un projet Google Cloud dans lequel vous disposez d'autorisations de Propriétaire, d'Éditeur ou de Lecteur :
Pick a cloud project to use:
[1] [my-project-1]
[2] [my-project-2]
...
Please enter your numeric choice:
Exécuter des cmdlets PowerShell
Après vous être authentifié, vous pouvez commencer à utiliser Cloud Tools for PowerShell. Ouvrez une fenêtre PowerShell et essayez d'exécuter les commandes suivantes.
Obtenez tous les buckets du projet en cours, d'un projet spécifique ou d'un bucket spécifique :
Répertoriez toutes les instances de Compute Engine associées à un projet :
Get-GceInstance -Project my-project-1 |
Sort Status |
Format-Table Name, Status -GroupBy Status
Status: RUNNING
Name Status
---- ------
my-vm-2 RUNNING
my-vm-3 RUNNING
Status: TERMINATED
Name Status
---- ------
my-vm-1 TERMINATED
Parcourir Cloud Storage avec le fournisseur PowerShell
Cloud Tools for PowerShell inclut un fournisseur PowerShell pour Cloud Storage. Ce fournisseur vous permet d'utiliser des commandes telles que cd, dir, copy et del pour parcourir et manipuler vos données dans Cloud Storage comme si elles se trouvaient sur un système de fichiers local.
Pour utiliser le fournisseur directement, vous pouvez lancer Cloud Tools for PowerShell à l'aide du raccourci situé dans le menu Démarrer. Cela lancera une console PowerShell dans laquelle le fournisseur est chargé :
# Navigate to Cloud Storage
cd gs:\
# Show the available buckets
ls
# Create a new bucket
mkdir my-new-bucket
Vous pouvez également rendre le fournisseur Cloud Storage disponible dans toutes les sessions PowerShell en important le module Cloud Tools for PowerShell à l'aide du cmdlet Import-Module GoogleCloud.
Étape suivante
Pour en savoir plus sur des cmdlets spécifiques, consultez la référence relative aux cmdlets Cloud Tools for PowerShell ou utilisez le système d'aide intégré à partir de PowerShell :
Get-Help New-GcsBucket
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Quickstart\n\nThis page shows how to enable Cloud Tools for PowerShell, authenticate\nwith the gcloud CLI, and run PowerShell cmdlets.\n\nBefore you begin\n----------------\n\nComplete the following steps:\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n1. Install the gcloud CLI from the PowerShell command line by running the following command as an administrator: \n\n```\nInstall-Module GoogleCloud\n```\n\n\u003cbr /\u003e\n\nAuthenticate with gcloud CLI\n----------------------------\n\nCloud Tools for PowerShell uses your credentials and settings stored in the\ngcloud CLI to enable the cmdlets. To use the cmdlets, first log in\nusing the gcloud CLI:\n\n1. At the command prompt, run the following command:\n\n ```\n gcloud init\n ```\n2. Accept the option to log in using your Google user account:\n\n `To continue, you must log in. Would you like to log in (Y/n)? Y`\n3. In your browser, log in to your Google user account when prompted and click\n **Allow** to grant permission to access Google Cloud resources.\n\n4. At the command prompt, select a Google Cloud project in which you\n have Owner, Editor, or Viewer permissions:\n\n ```\n Pick a cloud project to use:\n [1] [my-project-1]\n [2] [my-project-2]\n ...\n Please enter your numeric choice:\n ```\n\nRun PowerShell cmdlets\n----------------------\n\nAfter authenticating, you can start using Cloud Tools for PowerShell. Open a\nPowerShell window and try running the following commands.\n\nGet all buckets for the current project, for a specific project, or a specific\nbucket: \n\n```\n$currentProjBuckets = Get-GcsBucket\n$specificProjBuckets = Get-GcsBucket -Project my-project-1\n$bucket = Get-GcsBucket -Name my-bucket-name\n```\n\nList all Compute Engine instances associated with a project: \n\n```\nGet-GceInstance -Project my-project-1 |\n Sort Status |\n Format-Table Name, Status -GroupBy Status\n\n Status: RUNNING\n\nName Status\n---- ------\nmy-vm-2 RUNNING\nmy-vm-3 RUNNING\n\n Status: TERMINATED\n\nName Status\n---- ------\nmy-vm-1 TERMINATED\n```\n\nNavigate Cloud Storage with PowerShell provider\n-----------------------------------------------\n\nCloud Tools for PowerShell includes a PowerShell provider for\nCloud Storage. This provider allows you to use commands like\n`cd`, `dir`, `copy` and `del` to navigate and manipulate your data in\nCloud Storage as if the data were on a local file system.\n\nTo directly use the provider, you can start Cloud Tools for PowerShell using\nthe shortcut from the start menu. This will launch a PowerShell console with the\nprovider loaded: \n\n```\n# Navigate to Cloud Storage\ncd gs:\\\n# Show the available buckets\nls\n# Create a new bucket\nmkdir my-new-bucket\n```\n\nYou can also make the Cloud Storage provider available in any\nPowerShell session by importing the Cloud Tools for PowerShell module via\n`Import-Module GoogleCloud`.\n\nWhat's next\n-----------\n\nYou can learn more about specific cmdlets by referring to the\nCloud Tools for PowerShell [cmdlet\nreference](https://googlecloudplatform.github.io/google-cloud-powershell), or by\nusing the built-in help system from within PowerShell: \n\n```\nGet-Help New-GcsBucket\n```"]]