במסמך הזה מוסבר איך להתחבר למכונה וירטואלית (VM) של Windows באמצעות PowerShell.
לפני שמתחילים
-
אם עדיין לא עשיתם זאת, מגדירים אימות.
אימות הוא התהליך שבו הזהות שלכם מאומתת כדי לקבל גישה ל Trusted Cloud by S3NS שירותים ולממשקי API.
כדי להריץ קוד או דוגמאות מסביבת פיתוח מקומית, אפשר לבצע אימות ל-Compute Engine על ידי בחירה באחת מהאפשרויות הבאות:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
- Set a default region and zone.
אם עדיין לא יצרתם שם משתמש וסיסמה במכונה המרוחקת של Windows, יוצרים או מאפסים את הסיסמה ל-Windows.
מוסיפים כלל של חומת אש שפותח את היציאה
5986
ברשת ה-VPC שבה נמצאת המכונה של Windows Server.Trusted Cloudבתחנת העבודה המקומית, פותחים את מסוף PowerShell.
אופציונלי: אפשר לאתחל משתנה שיאחסן את פרטי הכניסה של המשתמש, כדי שלא תצטרכו להזין אותם בכל פעם שתתחברו למכונה. אם תדלגו על השלב הזה, תתבקשו להזין את שם המשתמש והסיסמה מאוחר יותר.
$credentials = Get-Credential
בוחרים אם ליצור סשן אינטראקטיבי של Powershell או להפעיל פקודות מרחוק ב-VM של Windows Server.
IP_ADDRESS
: כתובת ה-IP, שם ה-DNS או שם המחשב ב-Windows של המכונה שאליה רוצים להתחבר.SCRIPT
: פקודה אחת או יותר להרצה במכונה המרוחקת. לדוגמה, מציינים את הערךGet-EventLog -log "Windows PowerShell"
כדי לקבל רשימה של אירועים ביומן.- איך מנהלים את הגישה למכונות של כמה משתמשים בפרויקט או בארגון
- התחברות מאובטחת למכונות וירטואליות.
- העברת קבצים למכונות Linux.
חיבור באמצעות PowerShell
אם יש לכם תחנת עבודה של Windows עם PowerShell, תוכלו להתחבר למכונות של Windows Server דרך סשן PowerShell מרוחק.
יצירת סשן אינטראקטיבי ב-PowerShell
כדי ליצור סשן PowerShell, מריצים את הפקודה הבאה:
Enter-PSSession -ComputerName IP_ADDRESS -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Credential $credentials
מחליפים את
IP_ADDRESS
בכתובת ה-IP החיצונית, בשם ה-DNS או בשם המחשב ב-Windows של המכונה שאליה רוצים להתחבר.אחרי ההתחברות, שורת הפקודה תשתנה ותכלול את כתובת ה-IP של המכונה המרוחקת של Windows. עכשיו אפשר להשתמש במסוף כדי להריץ פקודות PowerShell במכונה המרוחקת של Windows Server.
הפעלת פקודות מרחוק ב-VM של Windows Server
לחלופין לפקודה
Enter-PSSession
, אפשר להריץ את הפקודהInvoke-Command
עם הדגל-ScriptBlock
כדי להריץ פקודות PowerShell במכונה המרוחקת בלי ליצור סשן אינטראקטיבי.Invoke-Command -ComputerName IP_ADDRESS -ScriptBlock { SCRIPT } -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Credential $credentials
מחליפים את מה שכתוב בשדות הבאים:
המאמרים הבאים
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-06-11 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-06-11 (שעון UTC)."],[[["This document guides you through connecting to a Windows virtual machine (VM) instance using PowerShell, enabling remote management and command execution."],["Before connecting, ensure you have set up authentication via the Google Cloud CLI or are using the Google Cloud console, and have created or reset your Windows password on the remote instance."],["Connecting to a Windows Server instance requires opening port 5986 in your Google Cloud VPC network's firewall rules, in order to accept remote PowerShell connections."],["You can establish either an interactive PowerShell session using `Enter-PSSession` or remotely invoke commands on the VM without an interactive session by using the `Invoke-Command` method."],["When a user connects to a VM, they can utilize all IAM permissions granted to the service account attached to that specific VM."]]],[]] -