שאלות נפוצות על POWERSHELL בעברית

By | April 12, 2015

translated-hebrew




הקונספט: השאלות הנפוצות ביותר אודות PowerShell.

את/ה יכול/ה להשתמש ברשימה זו בדרכים שונות:

כדי להעתיק / להדביק פקודות לתוך סקריפט מסוים
כדי לראות במהירות את התחביר של הפקודה ספציפית
כדי לשפר את הידע הטכני שלך
לגלות פקודות חדשות
כדי להכין ראיון עבודה


7 יולי 2015
עדכון
powershell-guru.com מחבר
hebrew.powershell-guru.com מקור
75
קטגוריות
610
שאלות


ACL
Active Directory
Alias
Arrays
Browsers
Certificates
Characters
CIM
Comments
COM Objects
Compare
Computer
Credentials
CSV
Culture
Date
Drives
Environment
Errors
Event Viewer
Files
Folders
Format Operator (-f)
Functions
GPO
GUI
Hardware
Hashtables
Help
History
Jobs
Keyboard
Loops
Math
Memory
Messages
Modules
Microsoft Excel
Microsoft Exchange
Microsoft Outlook
Microsoft SharePoint
Networking
Openfiles
Operators
Parameters
Password
Powershell ISE
Powershell v5
Printers
Processes
PSObject
Quest
Random
RDP
Regedit
Regex
Remote
Restore
Scheduled Tasks
Search
SCCM
Services
SMTP
Snapins
Sounds
Static .NET Methods
Strings
System
Try/Catch
Variables
Symantec Vault
Windows 2012
Windows Azure
Windows Forms
WMI
XML

System

כיצד לקבוע את הגרסה שלי של PowerShell?

כיצד להפעיל את PowerShell בגרסה אחרת לתאימות לאחור?
powershell.exe -Version 2.0

כיצד לדרוש גרסה מינימאלית של PowerShell (3.0 ומעלה) בתוך סקריפט עם PowerShell?
#Requires -Version 3.0

כיצד לדרוש הרשאות ניהול לסקריפט עם PowerShell?

כיצד לבדוק את הפרמטרים של הסקריפט עם PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

איך להשיג מידע עבור המשתמש הנוכחי עם PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

כיצד ליצור, לערוך ולטעון מחדש פרופיל עם PowerShell?

איך לעשות הפסקה של 5 שניות / דקות בסקריפט עם PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

כיצד להציג את זמן האתחול האחרון עם PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

כיצד להציג מקשי קיצור (type accelerators) עם PowerShell?

כיצד להציג את תוכניות ההפעלה עם PowerShell?

כיצד להסיר התקנת יישום עם PowerShell?

איך לעשות צילום מסך של כל שולחן העבודה או של חלון פעיל עם PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

איך להציג את ספירת ההודעות לתורים ב MSMQ עם PowerShell?

כיצד להגדיר את ה ” Power Shell Execution Policy” ב PowerShell?

כיצד ליצור קיצור דרך עם PowerShell?

איך להצמיד או לבטל הצמדת תכנית לשורת המשימות עם PowerShell?

כיצד לפתוח את Windows Explorer עם PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

איך לנהל רשימת מנהלי התקנים עם PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

כיצד ליצור GUID עם PowerShell?

איך להציג למיקום של הספרייה הזמנית עבור המשתמש הנוכחי עם PowerShell?
[System.IO.Path]::GetTempPath()

איך לאחד path ו child path לpath אחד בודד עם PowerShell?
Join-Path -Path C:\ -ChildPath \windows

כיצד להציג את כל רכיבי cmdlet “Get-*” עם PowerShell?
Get-Command -Verb Get

איך להציג תיקיות מערכת מיוחדות עם PowerShell?

איך לעלות קבצי ISO/ VHD עם PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

כיצד לבדוק גרסאות של .NET Framework מותקנות עם PowerShell?

כיצד לבדוק אם גרסת .NET Framework 4.5 מותקנת עם PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

איך להתחיל ולהפסיק transcript (כדי ליצור תיעוד של סשן של Windows PowerShell) עם PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

כיצד לשנות את הספרייה הנוכחית למיקום ספציפי עם PowerShell?
Set-Location -Path 'C:\scripts'

כיצד לנקות את המסך עם PowerShell?
Clear-Host
cls # Alias

כיצד לשנות את רזולוציית התצוגה עם PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

כיצד להגדיר חלון מסך מלא (full screen) עם PowerShell?
mode.com 300

כיצד לדעת ממדים (רוחב וגובה) של תמונות עם PowerShell?

כיצד להציג את מפתח המוצר של Windows עם PowerShell ?

Perfmon

איך להציג את “זמן מעבד%” הנוכחי (ממוצע) ב 5 שניות האחרונות (10 פעמים) עם PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

כיצד לטעון אסמבלרים עם PowerShell?

כיצד לבדוק את האסמבלרים הנוכחיים של .NET שטעונים עם PowerShell?

איך למצוא את הנתיב של (Global Assembly Cache) GAC עם PowerShell?

Clipboard

כיצד להעתיק תוצאות ללוח העריכה עם PowerShell?

כיצד להציג את התוכן של לוח העריכה עם PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

כיצד להציג את ה HOTFIXים המותקנים עם PowerShell?
Get-HotFix -ComputerName $computer

איך להציג את ה HOTFIXים אשר הותקנו לפני / אחרי תאריך מבוקש עם PowerShell?
Get-HotFix | Where-Object -FilterScript { $_.InstalledOn -lt ([DateTime]'01/01/2015') } # Before 01/01/2015
Get-HotFix | Where-Object -FilterScript {$_.InstalledOn -gt ([DateTime]'01/01/2015')} # After 01/01/2015

כיצד לבדוק האם HotFix מסוים מותקן עם PowerShell?
Get-HotFix -Id KB2965142

איך להציג ל HOTFIXים אשר מותקנים על מחשב מרוחק עם PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

איך להציג מידע על קובץ ההחלפה עם PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

איך להציג את הגודל המומלץ (MB) עבור קובץ ההחלפה עם PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

כיצד ליצור קובץ ההחלפה (4096 MB) על כונן (D:) עם PowerShell?

כיצד למחוק קובץ החלפה בכונן (C:) עם PowerShell?

Maintenance

כיצד לבדוק פיצול של כונן עם PowerShell?

כיצד לבדוק את שטח הדיסק של כוננים עם PowerShell?

Up


Files

כיצד לפתוח קובץ עם PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

כיצד לקרוא קובץ עם PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

איך לכתוב פלט לקובץ עם PowerShell?

איך להציג את השם המלא של קובץ הסקריפט הנוכחי עם PowerShell?
$MyInvocation.MyCommand.Path

כיצד לדחוס קבצים (zip) עם PowerShell?

כיצד לבטל דחיסה של קבצים / לפרוס קבצים ((Unzip עם PowerShell?

איך לראות את הקבצים בארכיון ZIP עם PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

כיצד להציג גודל של קובץ בKB עם PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

איך למצוא קבצים גדולים יותר או פחות מ 1 GB עם PowerShell?

כיצד להציג שם של קובץ ללא סיומת עם PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

כיצד להציג סיומת של קובץ עם PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

כיצד להציג את גרסת הקובץ של קובץ עם PowerShell?

איך להציג את גיבוב של קובץ PowerShell?
(Get-FileHash $file).Hash

איך להציג את ה checksums MD5 / SHA1 של קובץ עם PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

כיצד להציג קבצים מוסתרים עם PowerShell?

כיצד לבדוק אם לקובץ יש סיומת עם PowerShell?

כיצד להגדיר קובץ לקריאה בלבד עם PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

כיצד לשנות את תכונת LastWriteTime ל”שבוע שעבר” לקובץ עם PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

כיצד ליצור קובץ חדש עם PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

איך לשנות שם של קובץ עם PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

כיצד לשנות שמות עבור קבצים מרובים בתפזורת / ביחד עם PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

כיצד למחוק קובץ עם PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

כיצד להציג את 10 הקווים האחרונים של קובץ מסוים עם PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

כיצד לבטל את החסימה של מספר קבצים בתיקייה עם PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

כיצד להסיר שורות ריקות מקובץ עם PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

כיצד לבדוק האם קובץ מסוים קיים עם PowerShell?

כיצד להציג את הקובץ החדש / הישן ביותר שנוצר בתיקייה מסויימת עם PowerShell?

כיצד להסיר כפילויות של קווים מקובץ עם PowerShell?

איך להציג את הקבצים שנוצרו לפני יותר / פחות מחודש בתיקייה מסויימת עם PowerShell?

איך להציג את הקבצים שנוצרו לפני יותר / פחות משנה בתיקייה מסויימת עם PowerShell?

כיצד לייצא ערך של משתנה לקובץ עם PowerShell?
Set-Content -Path file.txt -Value $variable

איך לספור את מספר הקבצים (* .txt) בתיקייה עם PowerShell?

כיצד לחפש מחרוזת בתוך קבצים מרובים עם PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Test'

כיצד להציג את השורה הראשונה / האחרונה של קובץ עם PowerShell?

כיצד להציג מספר שורה מסוים של קובץ עם PowerShell?

איך לספור את מספר השורות של קובץ עם PowerShell?

איך לספור את מספר התווים והמילים של קובץ עם PowerShell?

כיצד להוריד קובץ עם PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

כיצד להציג את הנתיב המלא של קובץ מסוים עם PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

כיצד להעתיק קובץ אחד לתיקייה עם PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

כיצד להעתיק קובץ אחד למספר רב של תיקיות בPowerShell?

כיצד להעתיק קבצים מרובים לתיקייה אחת בPowerShell?
Get-ChildItem -Path 'C:\source' -Filter *.txt | Copy-Item -Destination 'C:\destination'

Up


Active Directory

Domain & Forest

Computers

Groups

Organizational Unit (OU)

Users

Domain & Forest

איך למצוא שרתי קטלוג כלליים ב- Active Directory עם PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

איך למצוא אתרים ב- Active Directory עם PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

איך למצוא את בקר התחום הנוכחי עם PowerShell?

איך למצוא את כל בקרי התחום בתחום מסויים עם PowerShell?

איך למצוא את כשלי שכפול ה AD עם PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

איך למצוא את ה” tombstone lifetime” ליער ב- Active Directory עם PowerShell?

איך להציג פרטים על היער / תחום ב- Active Directory עם PowerShell?

איך להציג את הנתיב של מיכל ה “אובייקטים שנמחקו (Deleted Objects) ” ב- Active Directory עם PowerShell?
(Get-ADDomain).DeletedObjectsContainer

כיצד להפעיל את תכונת סל המיחזור של AD ב- Active Directory עם PowerShell?

כיצד לשחזר חשבון AD מסל המיחזור ב- Active Directory עם PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

איך למצוא את חוקי ה FSMO עם PowerShell?

כיצד להתחבר לבקר תחום ספציפי עם PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

איך להציג את שרת הכניסה הנוכחי עם PowerShell?

כיצד לבצע “gpupdate” במחשב עם PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

כיצד ליצור קבוצה חדשה ב- Active Directory עם PowerShell?

כיצד להסיר קבוצה ב- Active Directory עם PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

כיצד להוסיף משתמש לקבוצה ב- Active Directory עם PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

כיצד להסיר משתמש מקבוצה ב- Active Directory עם PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

איך למצוא קבוצות ריקות (ללא חברים) ב- Active Directory עם PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

איך לספור קבוצות ריקות (ללא חברים) ב- Active Directory עם PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

איך להציג את חברי הקבוצה ב- Active Directory עם PowerShell?

איך להציג את חברי הקבוצה כולל החברים הרקורסיבים ב- Active Directory עם PowerShell?

איך לספור את מספר החברים בקבוצה עם / בלי החברים הרקורסיבים ב- Active Directory עם PowerShell?

Users

כיצד להשתמש ב wildcard במסנן של “”Get-ADUser ב- Active Directory עם PowerShell?

כיצד להעביר משתמש ל OU אחר ב- Active Directory עם PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

איך למצוא את כל ה (מקונן) למשתמש עם PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

איך להציג את ה members (שם קצר / חלקי) עבור משתמש עם PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

איך לשנות את השם (FullName), DisplayNameשם תצוגה ,שם פרטי , (FirstName) ושם המשפחה (LastName) לחשבון משתמש ב- Active Directory עם PowerShell?

כיצד לשנות את התיאור, משרד ומספר טלפון (Tele) לחשבון משתמש ב- Active Directory עם PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

כיצד להגדיר את תאריך התפוגה ל” 31/12/2015 “או” לעולם לא ” לחשבון משתמש ב- Active Directory עם PowerShell?

כיצד לפתוח/אנלוק (unlock) חשבון משתמש ב- Active Directory עם PowerShell?
Unlock-ADAccount $samAccountName

כיצד להפעיל / להשבית חשבון משתמש ב- Active Directory עם PowerShell?

כיצד להסיר חשבון משתמש ב- Active Directory עם PowerShell?
Remove-ADUser $samAccountName

כיצד לאפס סיסמא לחשבון משתמש מסויים ב- Active Directory עם PowerShell?

כיצד לאפס סיסמא עבור מספר חשבונות משתמש (בתפזורת) ב- Active Directory עם PowerShell?

כיצד למצוא מי הבעלים של קובץ מסויים ב- Active Directory עם PowerShell?

איך למצוא את ה- OU (יחידה ארגונית) למשתמש מסוים ב- Active Directory עם PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

איך למצוא חשבונות משתמשים שהינם מוגבלים (disabled users accounts) ב- Active Directory עם PowerShell?

איך למצוא חשבונות משתמשים שפג תוקפם ב- Active Directory עם PowerShell?
Search-ADAccount -AccountExpired

איך למצוא חשבונות משתמשים שהינם נעולים ב- Active Directory עם PowerShell?
Search-ADAccount -LockedOut

איך למצוא את ה- SID של חשבון משתמש ב- Active Directory עם PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

כיצד להמיר את שם המשתמש לSID ב- Active Directory עם PowerShell?

כיצד להמיר SID לשם המשתמש ב- Active Directory עם PowerShell?

איך לפצל את השם הייחודי (Distinguished Name) של חשבון משתמש עם Active Directory עם PowerShell?

איך למצוא את תאריך היצירה / שינוי של חשבון משתמש עם Active Directory עם PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

כיצד להציג את המאפיינים האופציונליים ומאפייני החובה למחלקת ” user ” עם Active Directory עם PowerShell?

איך להציג לנתיב LDAP עבור משתמש עם Active Directory עם PowerShell?

כיצד לשנות את ה- CN (Canonical Name) עבור משתמש עם Active Directory עם PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Test Powershell'

איך להציג את ה parent של היחידה הארגונית (OU) של משתמשים עם Active Directory עם PowerShell?

איך להציג את הבעלים של המשתמש (שיצר את החשבון) עם Active Directory עם PowerShell?

כיצד להמיר את תכונת pwdLastSet למשתמש עם Active Directory עם PowerShell?

Computers

כיצד לבדוק את הערוץ המאובטח בין המחשב המקומי והתחום עם PowerShell?
Test-ComputerSecureChannel

איך לתקן את הערוץ המאובטח בין המחשב המקומי והתחום עם PowerShell?
Test-ComputerSecureChannel -Repair

כיצד להשבית חשבון מחשב ב- Active Directory עם PowerShell?
Disable-ADAccount $computer

איך למצוא מחשבים עם מערכת הפעלה ספציפית ב- Active Directory עם PowerShell?

Organizational Unit (OU)

כיצד ליצור יחידה ארגונית (OU) ב- Active Directory עם PowerShell?
New-ADOrganizationalUnit -Name 'TEST' -Path 'DC=domain,DC=com'

כיצד להציג פרטים אודות (OU) יחידה ארגונית ב- Active Directory עם PowerShell?
Get-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Properties *

כיצד לשנות את התיאור של יחידה ארגונית (OU) ב- Active Directory עם PowerShell?
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Description 'My description'

כיצד להפעיל / לבטל את ההגנה על מחיקה בשוגג של יחידה ארגונית (OU) ב- Active Directory עם PowerShell?

כיצד לאפשר את המחיקה בשוגג לכל היחידה הארגונית (OU) ב- Active Directory עם PowerShell?

כיצד למחוק יחידה ארגונית (OU) מוגנת בפני מחיקה בשוגג ב- Active Directory עם PowerShell?

כיצד להמיר DistinguishedName של יחידה ארגונית (OU) לCanonicalName עם Active Directory עם PowerShell?

כיצד לרשום יחידות ארגוניות ריקות (OUs) עם PowerShell?

איך להציג מנהל של קבוצה עם PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

כיצד לחלץ כתובת IP v4 (80.80.228.8) עם Regex עם PowerShell?
$example = 'The IP address is 80.80.228.8'
$ip = [regex]::match($example,'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').value

כיצד לחלץ את כתובת ה – MAC (C0-D9-62-39-61-2D) עם מפריד “-” עם Regex עם PowerShell?
$example = 'The MAC address is C0-D9-62-39-61-2D'
$mac = [regex]::match($example,'([0-9A-F]{2}[-]){5}([0-9A-F]{2})').value

כיצד לחלץ את כתובת ה – MAC MAC (C0: D9: 62: 39: 61: 2D) עם מפריד “:” עם Regex עם PowerShell?
$example = 'The MAC address is C0:D9:62:39:61:2D'
$mac = [regex]::match($example,'((\d|([a-f]|[A-F])){2}:){5}(\d|([a-f]|[A-F])){2}').value

כיצד לחלץ תאריך (10/02/2015) עם Regex עם PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

כיצד לחלץ (כתובת אתר) URL (www.powershell-guru.com) עם Regex עם PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

כיצד לחלץ דוא”ל (user@domain.com) עם Regex עם PowerShell?
$example = 'The email is user@domain.com'
$email = [regex]::match($example,'(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b').value

כיצד לחלץ “גורו” (( “guru” מדוגמא של מחרוזת עם Regex עם PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

כיצד לחלץ “guru.com” מדוגמא של מחרוזת עם Regex עם PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

כיצד לחלץ “powershell-guru.com” מדוגמא של מחרוזת עם Regex עם PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

כיצד לחלץ “123” מדוגמא של מחרוזת עם Regex עם PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

כיצד לחלץ “$” (סימן דולר) מדוגמא של מחרוזת עם Regex עם PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

כיצד להחליף תו מסוים (* .com) בתו אחר (* .fr) במחרוזת עם Regex עם PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

כיצד לבצע escape עבור מחרוזת עם Regex עם PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

כיצד לכפות אסיפה של זיכרון על ידי אספן האשפה עם PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

כיצד להציג את גודל ה- RAM של מחשב מסויים עם PowerShell?

Up


Date

כיצד להציג את התאריך הנוכחי עם PowerShell?
Get-Date
[Datetime]::Now

כיצד להציג את התאריך בפורמטים שונים עם PowerShell?

כיצד להמיר תאריך (Datetime) לתאריך (מחרוזת) עם PowerShell?

כיצד להמיר תאריך (מחרוזת) לתאריך (Datetime) עם PowerShell?

כיצד לחשב את ההבדל (מספר ימים, שעות, דקות או שניות) בין שני תאריכים עם PowerShell?
(New-TimeSpan -Start $dateStart -End $dateEnd).Days
(New-TimeSpan -Start $dateStart -End $dateEnd).Hours
(New-TimeSpan -Start $dateStart -End $dateEnd).Minutes
(New-TimeSpan -Start $dateStart -End $dateEnd).Seconds

איך להשוות בין שני תאריכים עם PowerShell?
(Get-Date 2015-01-01) -lt (Get-Date 2015-01-30) # True
(Get-Date 2015-01-01) -gt (Get-Date 2015-01-30) # False

כיצד למיין מערך נתונים מסוים של תאריכים כDatetime עם PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

איך להתחיל ולהפסיק שעון עצר עם PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

כיצד להציג את היום הנוכחי בשבוע עם PowerShell?
(Get-Date).DayOfWeek #Sunday

כיצד להציג את התאריך של אתמול עם PowerShell?
(Get-Date).AddDays(-1)

כיצד להציג את מספר הימים בחודש מסויים (בחודש פברואר 2015) עם PowerShell?
[DateTime]::DaysInMonth(2015, 2)

כיצד ניתן לדעת שנה מעוברת עם PowerShell?
[DateTime]::IsLeapYear(2015)

כיצד להציג אזורי זמן עם PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

כיצד לקודד (לפורמט ASCII) ולפענח URL עם PowerShell?

מה הם המקבילות של הפקודות של הרשת המקומית עם PowerShell?

איך להציג כתובות IP עם PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

כיצד להשבית כתובת v6 IP (IPv6) עם PowerShell?

כיצד לאמת את כתובת ה- IP v4 (IPv4) עם PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

כיצד למצוא את כתובת ה- IP החיצונית עם PowerShell?

כיצד למצוא את שם המחשב המארח ( ( hostnameמכתובת ה- IP עם PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

איך למצוא את כתובת ה- IP משם מחשב מארח עם PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

איך למצוא את FQDN משם מחשב מארח עם PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

איך למצוא את תצורת הרשת(IP, Subnet, Gateway , (DNS עם PowerShell?

איך למצוא את כתובת ה- MAC עם PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

כיצד לבצע Ping למחשב עם PowerShell?

כיצד לבדוק האם מחשב מסויים מחובר לאינטרנט עם PowerShell?

כיצד לבצע איתור whois לאתר אינטרנט עם PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

כיצד להציג פרטים אודות IP ציבורי (Geolocation) עם PowerShell?

כיצד לבדוק האם יציאה מסויימת הינה פתוחה / סגורה עם PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

כיצד לבצע tracert עם PowerShell?
Test-NetConnection www.google.com -TraceRoute

איך לתקן את פרופיל חיבור רשת ביתית עם PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

איך להראות חיבורי יציאת TCP עם PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

כיצד לקצר כתובת אתר ארוכה לכתובת אתר מקוצרת עם PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

איך להציג את הגדרות ה- Proxy עם PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

כיצד לבדוק את מטמון ה- DNS במחשב מקומי עם PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

כיצד לנקות את מטמון ה- DNS במחשב מקומי עם PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

כיצד לנקות את מטמון ה- DNS במחשבים מרוחקים עם PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

כיצד לקרוא את קבצי Hosts עם PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

כיצד ליצור סיסמא אקראית עם PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

כיצד לשנות את הסיסמה המקומית למנהל בשרת מרוחק עם PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

איך למצוא את תאריך התפוגה של סיסמא של חשבון ב- Active Directory עם PowerShell?

Up


Printers

כיצד להציג את כל המדפסות של שרת ספציפי עם PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

כיצד להציג את כל היציאות של שרת ספציפי עם PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

כיצד לשנות את התגובה / מיקום המדפסת עם PowerShell?

איך לטהר (לבטל את כל העבודות) עבור מדפסת מסויימת עם PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

כיצד להדפיס דף בדיקה עבור מדפסת מסויימת עם PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

איך להציג את התור להדפסה עבור מדפסות עם PowerShell?

Up


Regedit

Read

כיצד להציג registry hives עם PowerShell?
Get-ChildItem -Path Registry::

איך להציג ערכי רישום (registry values ) וסוגי ערך עם PowerShell?

איך להציג את מפתחות המשנה של מפתח רישום מסוים עם PowerShell?

איך להציג את מפתחות המשנה של מפתח רישום ((registry key subkeys מסוים בדרך רקורסיבית עם PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

איך למצוא מפתחות משנה (subkeys ) בעלות שם ספציפי עם PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

כיצד להציג רק את שמו של מפתח המשנה (registry subkeys) של רישום מסוים (registery) עם PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

כיצד להציג את ערכי הרישום (registry values) עם PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

כיצד לקרוא ערך רישום ((registry value ספציפי עם PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

כיצד לקרוא ערך רישום ((registry value ספציפי במחשב מרוחק עם PowerShell?

Write

כיצד ליצור מפתח רישום חדש (registry key) עם PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

כיצד ליצור ערך רישום (registry value) עם PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

כיצד לשנות ערך רישום קיים (registry value) עם PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

כיצד למחוק ערך רישום (registry value) עם PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

כיצד למחוק מפתח רישום (registry key) עם PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

כיצד לבדוק האם מפתח רישום מסוים (registry key) קיים עם PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

כיצד לבדוק אם ערך רישום (registry value) קיים עם PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

כיצד להסיר רווחים של תווים (white-space) מהתחלה של מחרוזת עם PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

כיצד להסיר רווחים של תווים (white-space ) מסוף מחרוזת עם PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

כיצד להסיר רווחים של תווים (white-space ) (בהתחלה ובסיום) של מחרוזת עם PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

כיצד להמיר מחרוזת לאותיות גדולות עם PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

כיצד להמיר מחרוזת לאותיות קטנות עם PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

כיצד לבחור את תת המחרוזת “PowerShell” של המחרוזת “PowershellGuru” עם PowerShell?
$string.Substring(0,10)

כיצד לבחור את תת המחרוזת “גורו” של המחרוזת “PowershellGuru” עם PowerShell?
$string.Substring(10)

כיצד לבחור את המספר “123” של “Powershell123Guru” עם PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

איך להציג לאינדקס בסיס האפס של “גורו” של המחרוזת “PowershellGuru” עם PowerShell מבוססת אפס?
$string.IndexOf('Guru') # 10

כיצד לבדוק אם מחרוזת היא null או ריקה עם PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

כיצד לבדוק אם מחרוזת היא null, ריקה, או כוללת רק רווחים של תווים עם PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

כיצד לבדוק אם מחרוזת מכילה אות מסוימת עם PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

איך להציג אורך של מחרוזת עם PowerShell?
$string.Length

איך לשרשר שתי מחרוזות עם PowerShell?

כיצד לבדוק זהות בין אחד או כמה סוגריים “[]” במחרוזת עם PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

כיצד לבדוק זהות בין אחד או כמה סוגריים “()” במחרוזת עם PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

כיצד לבדוק זהות בין אחד או כמה סוגריים מסולסלים “{}” במחרוזת עם PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

כיצד לבדוק זהות בין אחד או כמה סוגריים משולשים “& lt; & gt;” במחרוזת עם PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

איך לבדוק זהות בין אותיות קטנות (ABC) במחרוזת עם PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

איך לבדוק זהות בין אותיות גדולות (ABC) במחרוזת עם PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

כיצד להתאים “[p ‘” (p אות קטנה) במחרוזת עם PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

כיצד להתאים “[P” (אות גדולה P) במחרוזת עם PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

כיצד להחליף שורה בשורה אחרת עם PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

כיצד להמיר פעולת חלוקה למחרוזת (באחוזים) עם PowerShell?
(1/2).ToString('P')

כיצד למיין מחרוזות המכילות מספרים עם PowerShell?

כיצד לבחור את המילה האחרונה של משפט מסוים עם PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ')[-1] # Returns Powershell

כיצד להציג את המילה הגדולה ביותר של משפט עם PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Powershell

איך לספור את מספר הפעמים שמחרוזת מסוימת קיימת בתוך משפט עם PowerShell?
$sentence = 'test test test Powershell'
[regex]::Matches($sentence, 'test').Count # Returns 3

כיצד להעתיק כל תו במחרוזת למערך נתונים מסוים תווים עם PowerShell?

כיצד להמיר את האות הראשונה לאותיות רישיות במחרוזת מסוימת עם PowerShell?

איך למלא (מימין או משמאל) מחרוזת עם PowerShell?

איך לקודד ולפענח מחרוזת ל Base64 עם PowerShell?

כיצד להמיר מספר בינארי למספר וההפך עם PowerShell?

כיצד להציג רק את תיקיית האב האחרונה בנתיב מסוים עם PowerShell?

כיצד להציג את הפריט האחרון בנתיב מסוים עם PowerShell?

Up


Math

כיצד להציג את שיטות מבנה הנתונים System.Math עם PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

איך להציג את הערך המוחלט עם PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

כיצד להציג את הזווית שסינוס שלה הוא המספר שצוין עם PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

איך להציג את ערך התקרה עם PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

איך להציג את ערך הרצפה עם PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

איך להציג את הלוגריתם הטבעי (בסיס e) של מספר מסוים עם PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

איך להציג את בסיס 10 לוגריתם של מספר מסוים עם PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

כיצד להציג את המקסימום מבין שני ערכים עם PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

כיצד להציג את המינימום מבין שני ערכים עם PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

כיצד להציג מספר בחזקה מסוימת עם PowerShell?
[Math]::Pow(2,4) #Returns 16

כיצד להציג ערך עשרוני לערך האינטרגרלי הקרוב ביותר עם PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

כיצד להציג את החלק האינטגרלי של מספר עשרוני שצוין עם PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

איך להציג את השורש הריבועי של מספר מסוים עם PowerShell?
[Math]::Sqrt(16) #Returns 4

כיצד להציג את הגודל הקבוע PI עם PowerShell?
[Math]::Pi #Returns 3,14159265358979

איך להציג את בסיס הלוגריתמים הטבעי (הקבוע) עם PowerShell?
[Math]::E #Returns 2,71828182845905

כיצד לבדוק האם מספר מסוים הוא זוגי או אי-זוגי עם PowerShell?
[bool]($number%2)

Up


Hashtables

כיצד ליצור טבלת גיבוב ריקה עם PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

כיצד ליצור טבלת גיבוב עם פריטים עם PowerShell?

כיצד ליצור טבלאות גיבוב מסודרות על ידי מפתח / שם ((ordered dictionary עם פריטים עם PowerShell?

כיצד להוסיף פריטים (זוג מפתחות-ערך) לטבלת גיבוב עם PowerShell?
$hashtable.Add('Key4', 'Value4')

איך להציג ערך ספציפי של מבנה נתונים מסוים עם PowerShell?

כיצד להציג את הערך המינימאלי של מבנה נתונים מסוים עם PowerShell?

איך להציג את הערך המרבי של מבנה נתונים מסוים עם PowerShell?

כיצד לשנות פריטים במבנה נתונים מסוים עם PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

כיצד להסיר פריטים במבנה נתונים מסוים עם PowerShell?
$hashtable.Remove('Key1')

כיצד למחוק מבנה נתונים מסוים עם PowerShell?
$hashtable.Clear()

כיצד לבדוק את נוכחותו של מפתח / ערך ספציפי במבנה נתונים מסוים עם PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

כיצד למיין לפי מפתח / ערך במבנה נתונים מסוים עם PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

כיצד ליצור מערך נתונים מסוים נתונים ריק עם PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

כיצד ליצור מערך נתונים מסוים עם פריטים עם PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

כיצד להוסיף פריטים למערך נתונים מסוים עם PowerShell?
$array += 'D'
[void]$array.Add('D')

כיצד לשנות פריט במערך נתונים מסוים עם PowerShell?
$array[0] = 'Z' # 1st item[0]

כיצד לבדוק את הגודל של מערך נתונים מסוים עם PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

כיצד לשחזר פריט / מספר / כל הפריטים במערך נתונים מסוים עם PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

כיצד להסיר פריטים ריקים במערך נתונים מסוים עם PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

כיצד לבדוק אם פריט קיים במערך נתונים מסוים עם PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains(