Closed cmreddyv closed 6 years ago
@cmreddyv Please use New-GceServiceAccountConfig
to create a service account object. You can then pass that object to the Add-GceInstance
cmdlet.
@quoctruong , every time i should create a newservice account config? can't i use the one which is already created, if you see when you run gcloud compute it will automatically selects the service account, similarly i want it in Powershell
able to fix it.
$serviceaccount = New-GceServiceAccountConfig -Email 'XXXXX' -Storage ReadWrite
Add-GceInstance -Name $machinename -BootDisk $disk -MachineType $machinetype -ServiceAccount $serviceaccount
Hi,
I am using PowerShell to create the gcloud environment, i have a startup script in bucket storage and when creating an instance the script is not able to download because of lack of permissions to the service account. I am not sure how to pass the service account parameter in the PowerShell.
Here is the snippet of my code:
$disk = Get-GceImage "windows-cloud" -Family "windows-2016" | New-GceDisk $diskname -SizeGb 100 -DiskType pd-standard
$config = New-GceInstanceConfig $machinename -MachineType $machinetype -BootDisk $disk -
$config | Add-GceInstance -ServiceAccount <what to pass here?>
Set-GceInstance $machinename -AddMetadata @{"windows-startup-script-url" = "storage url"