POWERSHELL HAQIDA O’ZBEK TILIDA FAQ

By | May 17, 2015

translated-uzbekistan


beta-v2-0


Concept: PowerShell haqida eng tez-tez so’raladigan savollar.

Ushbu ro’yxatni siz turli xil yo’llar bilan foydalanishingiz mumkin:

  • Topshiriqlarini skript ichiga ko’chirib olish / ko’shimcha qilib kiritilish uchun
  • Bir aniq topshiriqning sintaksni tez ko’rish uchun
  • Sizning texnik bilimini yaxshilash uchun
  • Yangi topshiriqlarini topish uchun
  • Ish intervyu tayyorlash

Yangilandi
Iyul 13, 2015
Muallif Steve Renard
Manba uzbek.powershell-guru.com
Kategoriyalar
75
Savollar
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

Qanday PowerShell mening versiyasini aniqlash uchun?

Qanday orqaga qarab muvofiqligi uchun boshqa versiyada PowerShell’i ishlatish?
powershell.exe -Version 2.0

Qanday PowerShell bilan skript bir minimal PowerShell versiyasini (3.0 va undan yuqori) talab?
#Requires -Version 3.0

Qanday PowerShell bilan bir buyruq fayli uchun ma’muriy imtiyozlarga talab?

Qanday PowerShell bilan skript parametrlarini nazorat qilish uchun?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Qanday PowerShell bilan joriy foydalanuvchi uchun ma’lumot olish mumkin?
[Security.Principal.WindowsIdentity]::GetCurrent()

Qanday yaratish, tahrir qilish, va PowerShell bilan bir holat qayta?

PowerShell skriptida 5 soniya/daqiqa tanaffus qanday qilish mumkin?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

PowerShell bilan oxirgi yuklash vaqtini qanday olish mumkin?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

PowerShell bilan tezlatgichlarning turlarini qanday olish mumkin?

PowerShell bilan avtomatik ravishda yuklanadigan dasturlar ro’yxatini qanday olish mumkin?

PowerShell bilan bir dasturni qanday olib tashlash mumkin?

PowerShell bilan butun ish stoli yoki faol deraza ekranining tasvirini qanday olish mumkin?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

PowerShell bilan MSMQ navbatlarning hisobi haqida xabarini qanday olish mumkin?

PowerShell bilan ijro tartibini qanday belgilash mumkin?

PowerShell bilan yorliqni qanday yaratish mumkin?

PowerShell bilan topshiriqlar paneliniga biror dasturni qanday mustahkamlashish yoki bo’shatish mumkin?

PowerShell bilan Windows Explorerni qanday ochish mumkin?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

PowerShell bilan moslama drayverlarning ro’yxatini qanday olish mumkin?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

PowerShell bilan GUIDni qanday olish mumkin?

PowerShell bilan joriy foydalanuvchining vaqtinchalik katalog joylashganini qanday olish mumkin?
[System.IO.Path]::GetTempPath()

PowerShell bilan yo’l va tarmoqlanib chiqqan yo’lini qanday bir yo’liga qushilish mumkin?
Join-Path -Path C:\ -ChildPath \windows

PowerShell bilan barcha “Get- *” cmdletlarining ro’yxatini qanday olish mumkin?
Get-Command -Verb Get

PowerShell bilan maxsus tizim papkalarning ro’yxatini qanday olish mumkin?

PowerShell bilan ISO / VHD fayllarni qanday o’rnatish mumkin?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

PowerShell bilan o’rnatilgan .NET Framework versiyalarini qanday tekshirish mumkin?

PowerShell bilan .NET Frameworkining 4.5 versiya o’rnatilganligini qanday tekshirish mumkin?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

PowerShell bilan izohlanishini (Windows PowerShell sessiyaning qayd qilishini yaratish) qanday boshlash va to’xtatish mumkin?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

PowerShell bilan joriy katalogining ma’lum bir joyga qanday o’zgartirish mumkin?
Set-Location -Path 'C:\scripts'

PowerShell bilan ekranni qanday tozalash mumkin?
Clear-Host
cls # Alias

PowerShell bilan ekran o’lchamlari qanday o’zgartirish mumkin?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

PowerShell bilan “to’liq ekran” oynasini qanday sozlash mumkin?
mode.com 300

PowerShell bilan Qanday rasmning o’lchamlarini (kengligi va balandligi) qanday olish mumkin?

PowerShell bilan Windows mahsulot kalitini qanday olish mumkin?

Perfmon

PowerShell bilan oxirgi 5 soniyaga (10 marta) joriy “% Protsessor vaqti” (o’rtacha) qanday olish mumkin?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

PowerShell bilan kompilyatsiya yig’ishlarini qanday o’rnatish mumkin?

PowerShell bilan joriy o’rnatilgan .NET kompilyatsiya yig’ishlarini qanday tekshirish mumkin?

PowerShell bilan GAC (Global kompilyatsiya yig’inining Keshi) yo’lini qanday topish mumkin?

Clipboard

PowerShell bilan natijalarini buferga Qanday nusxa ko’chirish mumkin?

PowerShell bilan almashish buferining tarkibini qanday olish mumkin?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

PowerShell bilan joriy o’zgarishlar qanday o’rnatilgan olish mumkin?
Get-HotFix -ComputerName $computer

PowerShell bilan o’zgarishlar bir sanadan oldin/keyin qanday o’rnatilgan olish mumkin?
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

PowerShell bilan qanday bir o’zgarish o’rnatilganligini tekshirish mumkin?
Get-HotFix -Id KB2965142

PowerShell bilan qanday bir o’zgarish uzoq kompyuterda o’rnatilish mumkin?
Get-HotFix -ComputerName $computer

Pagefile

PowerShell bilan almashish fayli haqida ma’lumotlarni qanday olish mumkin?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

PowerShell bilan almashish fayli uchun tavsiya etilgan hajmini (MB) qanday olish mumkin?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

PowerShell bilan (D:) diskida (4096 MB) almashish fayli qanday yaratish mumkin?

PowerShell bilan (C:) diskida almashtirish faylini qanday o’chirish mumkin?

Maintenance

PowerShell bilan bir diskining uzuq-yuluqligini qanday tekshirish mumkin?

PowerShell bilan disklar hajmini qanday tekshirish mumkin?

Up


Files

PowerShell bilan bir faylni qanday ochish mumkin?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

PowerShell bilan bir faylni qanday o’qish mumkin?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

PowerShell bilan qanday bir faylga chiqishini yozish mumkin?

PowerShell bilan joriy skript faylining to’liq nomini qanday olish mumkin?
$MyInvocation.MyCommand.Path

PowerShell bilan fayllarni qanday siqish / ziplash mumkin?

PowerShell bilan qanday fayllarni ochib olish / zipdan olish mumkin?

PowerShell bilan fayllarni ZIP arxivda qanday ko’rish mumkin?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

PowerShell bilan bir faylning hajmini KBda qanday ko’rish mumkin?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

PowerShell bilan 1 GB dan katta yoki kichik fayllarni qanday topish mumkin?

PowerShell bilan fayl nomini kengaytirishsiz qanday ko’rsatish mumkin?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

PowerShell bilan bir fayl kengaytirishni qanday ko’rish mumkin?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

PowerShell bilan bir fayl versiyasini qanday olish mumkin?

PowerShell bilan bir faylning heshini qanday olish mumkin?
(Get-FileHash $file).Hash

PowerShell bilan bir faylning MD5 / SHA1 summasini qanday olish mumkin?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

PowerShell bilan yashirin fayllarni qanday ko’rish mumkin?

PowerShell bilan fayl kengaytmalariga egaligini qanday tekshirish mumkin?

PowerShell bilan bir fayliga «faqat o’qish uchun» sifatini qanday belgilash mumkin?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

PowerShell bilan “LastWriteTime” (Ohiri yozish vaqti) xususiyatini haftaga qanday o’zgartirish mumkin?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

PowerShell bilan yangi fayl yaratish qanday mumkin?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

PowerShell bilan bir faylni qayta nomlash qanday mumkin?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

PowerShell bilan bir necha fayllarnini turkumi / tupi qanday qayta nomlash mumkin?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

PowerShell bilan faylni qanday o’chirish mumkin?
Remove-Item -Path 'C:\scripts\file.txt'

PowerShell bilan bir faylning eng so’nggi 10 satrlarni qanday ko’rish mumkin?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

PowerShell bilan bir papkada bir necha fayllarni qanday ochish mumkin?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

PowerShell bilan bir faylida bo’sh satrlarni qanday olib tashlash mumkin?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

PowerShell bilan bir fayl mavjudligini qanday tekshirish mumkin?

PowerShell bilan bir papkada eng yangi / eng oldin yaratilgan faylni qanday olish mumkin?

PowerShell bilan bir faylidagi nusxa satrlarni qanday olib tashlash mumkin?

PowerShell bilan bir papkada 1 oydan ko’p yoki kam vaqtida yaratilgan fayllarni qanday olish mumkin?

PowerShell bilan bir papkada 1 yildan ko’p yoki kam vaqtida yaratilgan fayllarni qanday olish mumkin?

PowerShell bilan Qanday o’zgaruvchining tarkibini bir faylga qanday eksport qilish mumkin?
Set-Content -Path file.txt -Value $variable

PowerShell bilan bir papkada (* .txt) fayllar sonini qanday hisoblash mumkin?

PowerShell bilan bir nechta fayl ichida bir qatorini qanday izlash mumkin?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

PowerShell bilan bir faylning birinchi / so’nggi satrni qanday ko’rsatish mumkin?

PowerShell bilan bir faylida ma’lum bir satrning raqamini qanday ko’rish mumkin?

PowerShell bilan bir fayl satrlarning sonini qanday hisoblash mumkin?

PowerShell bilan bir faylida belgilar va so’zlar sonini qanday hisoblash mumkin?

PowerShell bilan bir faylni qanday yuklab olish mumkin?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

PowerShell bilan bir faylining to’liq yo’lini qanday ko’rish mumkin?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

PowerShell bilan bir faylni bir jildga qanday nusxa ko’chirish mumkin?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

PowerShell bilan bir faylni bir necha jildlarga qanday ko’chirib olish mumkin?

PowerShell bilan bir necha fayllarni bir jildgada qanday ko’chirib olish mumkin?
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

PowerShell bilan Global katalog serverlarini Joriy jilda qanday topish mumkin?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

PowerShell bilan Joriy jildida saytlarni qanday topish mumkin?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

PowerShell bilan joriy domen tekshiruvchisini qanday topish mumkin?

PowerShell bilan bir domen ichida barcha domen tekshiruvchilarini qanday topish mumkin?

PowerShell bilan AD replika xatolarni qanday topish mumkin?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

PowerShell bilan Joriy jildida o’rmon uchun tombstounning muddatini qanday topish mumkin?

PowerShell bilan Joriy jildida o’rmon / domen ma’lumotlarni qanday olish mumkin?

PowerShell bilan Joriy jildida “O’chirilgan Ob’ektlar” konteyneriga yo’lini qanday olish mumkin?
(Get-ADDomain).DeletedObjectsContainer

PowerShell bilan Joriy jildida AD Chiqindi qutisi xususiyatini qanday yoqish mumkin?

PowerShell bilan Joriy jildida Chiqindi qutisi bir AD Hisobini qanday qayta tiklash mumkin?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

PowerShell bilan FSMO rollarni qanday topish mumkin?

PowerShell bilan ma’lum bir domenning tekshiruviga qanday ulanish mumkin?
Get-ADUser -Identity $user -Server 'serverDC01'

PowerShell bilan joriy kirish serverni qanday olish mumkin?

PowerShell bilan bir kompyuterda “gpupdate” qanday amalga oshirish mumkin?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

PowerShell bilan Joriy jildida yangi guruhni qanday yaratish mumkin?

PowerShell bilan Joriy jildida bir guruhini qanday olib tashlash mumkin?
Remove-ADGroup -Identity 'PowershellGuru'

PowerShell bilan Joriy jildida bir guruhga bir foydalanuvchini qanday kiritish mumkin?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

PowerShell bilan Joriy jildida bir guruhdan bir foydalanuvchini Qanday o’chirish mumkin?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

PowerShell bilan Joriy jildida bo’sh guruhlarni (a’zolarisiz) qanday topish mumkin?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

PowerShell bilan Joriy jildida bo’sh guruhlarni (a’zolarisiz) qanday hisoblash mumkin?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

PowerShell bilan Joriy jildida bir guruh a’zolarini qanday olish mumkin?

PowerShell bilan Joriy jildida rekursiv a’zolari bilan bir guruhida a’zolarini qanday olish mumkin?

PowerShell bilan Joriy jildida rekursiv a’zolari bilan / rekursiv a’zolarisiz guruhning a’zolari sonini qanday hisoblash mumkin?

Users

PowerShell bilan Joriy jildida “Get-ADUser” (Foydalanuvchi ADni olish) filtrining Vildkartini qanday foydalanish mumkin?

PowerShell bilan foydalanuvchini boshqa OUga qanday ko’chib olish mumkin?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

PowerShell bilan bir foydalanuvchi uchun (Ichki) barcha a’zolarni qanday topish mumkin?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

PowerShell bilan bir foydalanuvchi uchun (qisqa nomi / kesilgan) a’zolarni qanday olish mumkin?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

PowerShell bilan Joriy jildida bir foydalanuvchining hisob nomiga Nomini (To’lik nomi), (Ko’rsatildan nomi), Berilgan nomi(Birinchi nomi), va familiyasi (Familiyasi) qanday qayta nomlash mumkin?

PowerShell bilan joriy jildida bir foydalanuvchi uchun tavsifi, ofisi va telefon raqamini qanday o’zgartirish mumkin?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

PowerShell bilan Joriy jildida bir foydalanuvchi uchun o’tish sanasi “31/12/2015″ga yoki “Hech qachon” qanday o’rnatish mumkin?

PowerShell bilan joriy jildida bir foydalanuvchi uchun hisob qulfini qanday ochish mumkin?
Unlock-ADAccount $samAccountName

PowerShell bilan Joriy jildida bir foydalanuvchi hisobini qanday yoqish/o’chirish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchining hisobini qanday olib tashlash mumkin?
Remove-ADUser $samAccountName

PowerShell bilan joriy jildida bir foydalanuvchi uchun qanday parol o’rnatish mumkin?

PowerShell bilan bir necha foydalanuvchilar uchun (hajmida) hisoblarining parollarini qanday o’rnatish mumkin?

PowerShell bilan Joriy jildida bir faylning egasini qanday topish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchi uchun OU (tashkiliy birligini) qanday topish mumkin?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

PowerShell bilan Joriy jildida o’chirilgan foydalanuvchilarning hisoblarini qanday topish mumkin?

Qanday PowerShell bilan Joriy jild Muddati o’tgan foydalanuvchi hisob topish mumkin?
Search-ADAccount -AccountExpired

PowerShell bilan Joriy jildida qulflangan foydalanuvchilarning hisoblarini qanday topish mumkin?
Search-ADAccount -LockedOut

PowerShell bilan Joriy jildida bir foydalanuvchi hisobining SIDni qanday topish mumkin?
(Get-ADUser $user -Properties SID).SID.Value

PowerShell bilan Joriy jildida foydalanuvchi nomini SIDga qanday o’zgartirish mumkin?

PowerShell bilan Joriy jildida bir SIDni foydalanuvchi nomiga qanday aylantirish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchining hisobida maxsus ismini qanday bo’lish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchi hisobini yaratish / o’zgartirish sanasi qanday topish mumkin?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

PowerShell bilan Joriy jildida “Foydalanuvchi” sinfning ixtiyoriy va majburiy xususiyatlarini qanday ko’rsatish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchining LDAP yo’lini qanday olish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchi CN (Kanonikal nomi) qanday o’zgartirish mumkin?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

PowerShell bilan Joriy jildida bir Foydalanuvchi tashkiliy birligining (OU) ota-onani qanday olish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchi egasini (hisobni yaratilgan) qanday olish mumkin?

PowerShell bilan Joriy jildida bir foydalanuvchi PwdLastSet xususiyatini qanday aylantirish mumkin?

Computers

PowerShell bilan mahalliy kompyuter va domen o’rtasida xavfsiz kanalini qanday sinash mumkin?
Test-ComputerSecureChannel

PowerShell bilan mahalliy kompyuter va domen o’rtasida xavfsiz kanalini qanday rekonstruksiya qilish mumkin?
Test-ComputerSecureChannel -Repair

PowerShell bilan Joriy jildida kompyuter yozuvini qanday o’chirish mumkin?
Disable-ADAccount $computer

PowerShell bilan Joriy jildida muayyan operatsion tizimlari bilan kompyuterlarini qanday topish mumkin?

Organizational Unit (OU)

PowerShell bilan Joriy jildida bir tashkilot birligini (OU) qanday yaratish mumkin?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

PowerShell bilan Joriy jildida tashkiliy birligi (OU) ma’lumotlarni qanday olish mumkin?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

PowerShell bilan Joriy jildida tashkiliy birligini (OU) qanday tavsifi o’zgartirish mumkin?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

PowerShell bilan Joriy jildida tashkilot birligini (OU) tasodufiy o’chirishdan himoyalangan xususiyatini qanday yoqish / o’chirish mumkin?

PowerShell bilan Joriy jildida barcha tashkiliy birligilar (OU) uchun tasodifiy o’chirib tashlashday himoyalangan xususiyatini qanday faollashtirish mumkin?

PowerShell bilan Joriy jildida tasodufiy o’chirishdan himoyalangan bir tashkilot birligini (OU) qanday yo’q qilish mumkin?

PowerShell bilan Joriy jildida Maxsus nomini Kanonikal Ismga ega tashkilot birligiga (OU) qanday o’zgartirish mumkin?

PowerShell bilan bo’sh tashkilot birligilarning (OU) ro’yxatini qanday olish mumkin?

PowerShell bilan bir guruh menejeri qanday olish mumkin?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

PowerShell bilan Regex bilan IP-manzil v4 (80.80.228.8) qanday chiqarib olish mumkin?
$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

PowerShell bilan Regex bilan “-” ajratishi bir MAC-manzilni (C0-D9-62-39-61-2D) qanday chiqarib olish mumkin?
$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

PowerShell bilan “:” ajratish bilan MAC-manzilnini (2D: D9: 62: 39: 61 C0) Regex bilan qanday chiqarib olish mumkin?
$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

PowerShell bilan Regex bilan bir sanani (10/02/2015) qanday chiqarib olish mumkin?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

PowerShell bilan Regex bilan bir URL (www.powershell-guru.com) qanday chiqarib olish mumkin?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

PowerShell bilan Regex bilan bir elektron pochtani (user@domain.com) qanday chiqarib olish mumkin?
$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

PowerShell bilan Regex bilan satr misolidan «guru»ni qanday chiqarib olish mumkin?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

PowerShell bilan Regex bilan satr misolidan “guru.com”ni qanday chiqarib olish mumkin?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

PowerShell bilan Regex bilan satr misolidan “powershell-guru.com”ni qanday chiqarib olish mumkin?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

PowerShell bilan Regex bilan satr misolidan “123”ni qanday chiqarib olish mumkin?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

PowerShell bilan Regex bilan satr misolidan “$” (dollar belgisini) qanday chiqarib olish mumkin?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

PowerShell bilan Regex bilan satr ichida bir belgi (*.com) o’rniga boshqa (*.fr) belgini qanday quyish mumkin?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

PowerShell bilan Regex bilan satr ichida bir belgini qanday qochib olish mumkin?
[regex]::Escape('\\server\share')

Up


Memory

PowerShell bilan axlat terishi tomonidan xotirani to’plashini qanday majburlash mumkin?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

PowerShell bilan bir kompyuterning RAM hajmini qanday olish mumkin?

Up


Date

PowerShell bilan joriy sanani qanday olish mumkin?
Get-Date
[Datetime]::Now

PowerShell bilan turli formatlarda qanday sanani ko’rsatiladi?

PowerShell bilan sananing formati (DATETIME) qanday qilib sanaga (satr formatida) aylantirish mumkin?

PowerShell bilan sanani (satr formatida) sanaga (Datetime formatida) qanday aylantirish mumkin?

PowerShell bilan ikki sana orasida (kunlar soni, soat, daqiqa, yoki soniya) qanday farq hisoblash mumkin?
(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 bilan ikki sanalarni qanday solishtirish mumkin?
(Get-Date 2015-01-01) -lt (Get-Date 2015-01-30) # True
(Get-Date 2015-01-01) -gt (Get-Date 2015-01-30) # False

PowerShell bilan “DATETIME” massivini qanday bir qatorga tartiblashtirish mumkin?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

PowerShell bilan sekundomerni qanday boshlash va to’xtatish mumkin?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

PowerShell bilan haftaning hozirgi kunini qanday olish mumkin?
(Get-Date).DayOfWeek #Sunday

PowerShell bilan kechagi sanani qanday olish mumkin?
(Get-Date).AddDays(-1)

PowerShell bilan bir oy ichida kun sonini (2015 yil fevral oyining) qanday olish mumkin?
[DateTime]::DaysInMonth(2015, 2)

PowerShell bilan bir pog’ona yilini qanday bilish mumkin?
[DateTime]::IsLeapYear(2015)

PowerShell bilan vaqt hududlarini qanday ro’yhatga chiqarish mumkin?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

PowerShell bilan URLni (ASCII formatida) qanday kodlash va kodni ochish mumkin?

PowerShell bilan ona tarmoq buyruqlar o’xshashlar nima?

PowerShell bilan IP-manzili qanday olish mumkin?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

PowerShell bilan IP-manzil v6 (IPv6) qanday o’chirish mumkin?

PowerShell bilan bir IP-manzil v4 (IPv4) qanday tekshirish mumkin?
if([ipaddress]'10.0.0.1'){'validated'}

PowerShell bilan tashqi IP-manzilini qanday topish mumkin?

PowerShell bilan bir IP-manzilining Hostname (Egasining nomi) qanday topish mumkin?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

PowerShell bilan Hostname (Egasining nomi)dan bir IP-manzilini qanday topish mumkin?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

PowerShell bilan bir hostname (Egasining nomi)dan FQDN qanday topish mumkin?
[System.Net.Dns]::GetHostByName($computer).HostName

PowerShell bilan tarmoq konfiguratsiyani (IP, Quyi Tarmoq, Gateway va DNS)larini qanday topish mumkin?

PowerShell bilan MAC manzilini qanday topish mumkin?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

PowerShell bilan bir kompyuterni qanday Ping qilish mumkin?

PowerShell bilan Kompyuter Internetga ulanganligini qanday tekshirish mumkin?

PowerShell bilan bir veb-sayti “whois” qo’ng’irog’ini qanday qilish mumkin?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

PowerShell bilan bir jamoat IP (Geo pozitsiyani) tafsilotlarni qanday olish mumkin?

PowerShell bilan porti ochiqligini / yopiqligini qanday tekshirish mumkin?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

PowerShell bilan “tracert”ni qanday amalga oshirish mumkin?
Test-NetConnection www.google.com -TraceRoute

PowerShell bilan uy tarmoq ulanishi profili qanday tuzatish mumkin?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

PowerShell bilan TCP port bog’lanishni qanday ko’rsatish mumkin?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

PowerShell bilan uzoq URLni bir kichik URLga qanday qisqartirish mumkin?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

PowerShell bilan qanday proksi olish mumkin?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

PowerShell bilan mahalliy kompyuterda DNS keshni qanday tekshirish mumkin?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

PowerShell bilan mahalliy kompyuterda DNS keshni qanday tozalash mumkin?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

PowerShell bilan uzoq kompyuterlarda DNS keshni qanday tozalash mumkin?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

PowerShell bilan Xostlar faylini qanday o’qish mumkin?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

PowerShell bilan tasodifiy parolni qanday ishlab chiqarish mumkin?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

PowerShell bilan uzoq serverda bir rahbarning mahalliy parolni qanday o’zgartirish mumkin?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

PowerShell bilan Joriy jild hisobi parol o’tish sanasi qanday topish mumkin?

Up


Printers

PowerShell bilan ma’lum bir server uchun barcha printerlarni qanday ro’yxatga olish mumkin?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

PowerShell bilan ma’lum bir server uchun barcha portlarni qanday ro’yxatlash mumkin?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

PowerShell bilan printerning Izoh / o’rnini qanday o’zgartirish mumkin?

PowerShell bilan printerning qanday chop etishni tozalash (barcha ishlarini bekor qilish) mumkin?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

PowerShell bilan printerning bir sinov sahifasini qanday chop mumkin?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

PowerShell bilan printerning ishlar navbatlarini qanday olish mumkin?

Up


Regedit

Read

PowerShell bilan registrlarning ro’yxatga olish kitoblarini qanday ro’yxatga chiqarish mumkin?
Get-ChildItem -Path Registry::

PowerShell bilan ro’yxatga olish kitobi tartibini va tartib turlarini qanday olish mumkin?

PowerShell bilan ro’yxatga olish kitobi kaliti pastki kalitlarini qanday ro’yxatga olish mumkin?

PowerShell bilan ro’yxatga olish kitobi kaliti pastki kalitlarini qanday ro’yxatga olish mumkin?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

PowerShell bilan ma’lum bir nom bilan pastki kalitlarini qanday topish mumkin?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

PowerShell bilan ro’yxatga olish kitobi pastki kalitlari faqat nomini qanday qaytish mumkin?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

PowerShell bilan ro’yxatga olish kitobi tartiblarini qanday ro’yxatga olish mumkin?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

PowerShell bilan ma’lum bir ro’yxatga olish kitobi qiymatini qanday o’qish mumkin?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

PowerShell bilan bir uzoq kompyuterda ma’lum bir ro’yxatga olish kitobi qiymatini qanday o’qish mumkin?

Write

PowerShell bilan yangi ro’yxatga olish kitobi kaliti qanday yaratish mumkin?
New-Item -Path 'HKCU:\Software\MyApplication'

PowerShell bilan ro’yxatga olish kitobi qiymatini qanday yaratish mumkin?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

PowerShell bilan mavjud bo’lgan ro’yxatga olish kitobi qiymatini qanday o’zgartirish mumkin?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

PowerShell bilan ro’yxatga olish kitobi qiymatini qanday o’chirish mumkin?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

PowerShell bilan bir kalitini ro’yxatga olish kitobi qanday yo’q qilish mumkin?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

PowerShell bilan ro’yxatga olish kitobi kaliti mavjudligini qanday sinash mumkin?
Test-Path -Path 'HKCU:\Software\MyApplication'

PowerShell bilan ro’yxatga olish kitobi qiymati mavjudligini qanday sinash mumkin?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

PowerShell bilan satr boshidan oq-probel belgilarni qanday olib tashlash mumkin?
$string = ' PowershellGuru'
$string = $string.TrimStart()

PowerShell bilan satr ohiridan oq-probel belgilarni qanday olib tashlash mumkin?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

PowerShell bilan satr boshidan va ohiridan oq-probel belgilarni qanday olib tashlash mumkin?
$string = ' PowershellGuru '
$string = $string.Trim()

PowerShell bilan satrni harflar yuqori formatiga qanday aylantirish mumkin?
$string = 'powershellguru'
$string = $string.ToUpper()

PowerShell bilan satrni harflar pastki formatiga qanday aylantirish mumkin?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

PowerShell bilan “PowerShellGuru” satrning o’z ichiga oladigan satrni “PowerShell”ni qanday tanlash mumkin?
$string.Substring(0,10)

PowerShell bilan “PowerShellGuru” satrning o’z ichiga oladigan satrni “Guru”ni qanday tanlash mumkin?
$string.Substring(10)

PowerShell bilan “PowerShell123Guru” satrning o’z ichiga oladigan satrni “123”ni qanday tanlash mumkin?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

PowerShell bilan “PowerShellGuru” satrning nol’da asoslangan indeks “Guru” satrni qanday olish mumkin?
$string.IndexOf('Guru') # 10

PowerShell bilan bir satr nol yoki bo’sh bolganligini qanday tekshirish mumkin?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

PowerShell bilan bir satr nol yoki bo’sh bo’lganligini yoki faqat oq-probel belgilar tashkil topgan bo’lganligini qanday tekshirish mumkin?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

PowerShell bilan bir satr ma’lum bir belgini o’z ichiga olgan bolganligini qanday tekshirish mumkin?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

PowerShell bilan satr uzunligini qanday qaytish mumkin?
$string.Length

PowerShell bilan ikki satrlari qanday qo’shish mumkin?

PowerShell bilan satrda bir yoki bir necha to’g’ri qavslar “[ ]” qanday solishtirish mumkin?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

PowerShell bilan satrda bir yoki bir necha oddiy qavslar “( )” qanday solishtirish mumkin?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

PowerShell bilan satrda bir yoki bir necha egri qavslar “{ }” qanday solishtirish mumkin?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

PowerShell bilan satrda bir yoki bir necha burchakli qavslar “{ }” qanday solishtirish mumkin?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

PowerShell bilan satrda har qanday kichik harflar (abc) qanday solishtirish mumkin?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

PowerShell bilan har qanday katta harfni (ABC) qanday solishtirish mumkin?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

PowerShell bilan satrda “[p” (p kichik) qanday solishtirish mumkin?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

PowerShell bilan satrda “[P” (P katta) qanday solishtirish mumkin?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

PowerShell bilan bir satrni boshqa satr bilan qanday almashtirich mumkin?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

PowerShell bilan bir bo’linish jarayonini bir satrga (foizga) qanday aylantirish mumkin?
(1/2).ToString('P')

PowerShell bilan raqamlarini o’z ichiga olgan satrlarini qanday tartiblashtirish mumkin?

PowerShell bilan bir jumlaning oxirgi so’zini qanday tanlash mumkin?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

PowerShell bilan bir gapning eng katta so’zini qanday olish mumkin?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

PowerShell bilan bir satrning bir jumla ichida mavjud sonini qanday hisoblash mumkin?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

PowerShell bilan bir satrning har bir belgini belgilar massiviga qanday nusxa ko’chirish mumkin?

PowerShell bilan satrning birinchi harfni bosh harfga qanday aylantirish mumkin?

PowerShell bilan satrni qanday pad (chap yoki o’ng) qilish mumkin?

PowerShell bilan satrni Base64ga qanday kodlash va koddan olish mumkin?

PowerShell bilan sonini qanday ikki raqamli formatiga (va formatidan) aylantirish mumkin?

PowerShell bilan yo’lida qanday faqat oxirgi ota-papkani qaytish mumkin?

PowerShell bilan yo’lida qanday faqat oxirgi elementni qaytish mumkin?

Up


Math

PowerShell bilan System.Math sinf usullarini qanday ro’yxatga olish mumkin?
[System.Math] | Get-Member -Static -MemberType Method

PowerShell bilan absolyut qiymatini qanday qaytarib olish mumkin?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

PowerShell bilan belgilangan soniga teng bo’lgan sinus burchagini qanday qaytish mumkin?
[Math]::ASin(1) #Returns 1,5707963267949

PowerShell bilan shift qiymatini qanday qaytish mumkin?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

PowerShell bilan past qiymatini qanday qaytish mumkin?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

PowerShell bilan belgilangan raqamining tabiiy (tayanch “e”ga teng bo’lgan) logaritmni qanday qaytish mumkin?
[Math]::Log(4) #Returns 1,38629436111989

PowerShell bilan belgilangan raqamining o’nli (tayanch 10ga teng bo’lgan) logaritmni qanday qaytish mumkin?
[Math]::Log10(4) #Returns 0,602059991327962

PowerShell ikki qiymatidan qattasini qanday qaytish mumkin?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

PowerShell ikki qiymatidan kichikligini qanday qaytish mumkin?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

PowerShell raqamining belgilangan darajada qanday qaytish mumkin?
[Math]::Pow(2,4) #Returns 16

PowerShell bilan o’nli qiymatini eng yaqin integral qiymatiga qanday qaytish mumkin?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

PowerShell belgilangan o’nli raqamining integral qismini qanday qaytish mumkin?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

PowerShell bilan belgilangan raqamining kvadrat ildizini qanday qaytish mumkin?
[Math]::Sqrt(16) #Returns 4

PowerShell bilan Pi konstantasini qanday qaytish mumkin?
[Math]::Pi #Returns 3,14159265358979

PowerShell bilan tabiiy logarifmik bazasini (konstanta e)ni qanday qaytish mumkin?
[Math]::E #Returns 2,71828182845905

PowerShell bilan raqami toq yoki juftligini qanday tekshirish mumkin?
[bool]($number%2)

Up


Hashtables

PowerShell bilan bo’sh Hash jadvalini qanday yaratish mumkin?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

PowerShell bilan ob’ektlar bilan Hash jadvalini qanday yaratish mumkin?

PowerShell bilan bilan kaliti / nomidan sortirovka qilingan (tartiblangan lug’at) ob’ektlar bilan Hash jadvalini qanday yaratish mumkin?

PowerShell bilan Hash jadvaliga ob’ektlarini (kalit-qiymati jufti) qanday kiritish mumkin?
$hashtable.Add('Key4', 'Value4')

PowerShell bilan Hash jadvaliga qanday ma’lum bir qiymatini olish mumkin?

PowerShell bilan Hash jadvalidan minimal qiymatini qanday olish mumkin?

PowerShell bilan Hash jadvalidan maksimal qiymatini qanday olish mumkin?

PowerShell bilan Hash jadvalida ma’lumotlarini qanday o’zgartirish mumkin?
$hashtable.Set_Item('Key1', 'Value1Updated')

PowerShell bilan Hash jadvalida ma’lumotlarini qanday olib tashlash?
$hashtable.Remove('Key1')

PowerShell bilan Hash jadvalini qanday tozalash mumkin?
$hashtable.Clear()

PowerShell bilan Hash jadvalida ma’lum bir kalit / qiymat mavjudligini qanday tekshirish mumkin?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

PowerShell bilan Hash jadvalida kalit / qiymat asosan qanday tartiblashtirish mumkin?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

PowerShell bilan bo’sh massivini qanday yaratish mumkin?
$array = @()
$array = [System.Collections.ArrayList]@()

PowerShell bilan ob’ektlar bilan bir massivini qanday yaratish mumkin?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

PowerShell bilan bir massiviga ob’ektlarini qanday kiritish mumkin?
$array += 'D'
[void]$array.Add('D')

PowerShell bilan bir massivida bir ob’ektini qanday o’zgartirish mumkin?
$array[0] = 'Z' # 1st item[0]

PowerShell bilan bir massivining hajmini qanday tekshirish mumkin?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

PowerShell bilan bir / bir necha / barcha ob’ektlarini massividan qanday olish mumkin?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

PowerShell bilan massividan bo’sh ob’ektlarini qanday olib tashlash mumkin?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

PowerShell bilan massivida bir ob’ekt mavjudligini qanday tekshirish mumkin?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

PowerShell bilan bir massivida bir element indeksini qanday topish mumkin?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

PowerShell bilan bir massivida ob’ektlarning tartibini qanday teskari qilish mumkin?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

PowerShell bilan tasodifiy ob’ektni qanday yaratish mumkin?
$array | Get-Random

PowerShell bilan massivini kutarilayotgan / tushayotgan tarzda qanday tartiblashtirish mumkin?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

PowerShell bilan massivdagi ob’ektlar sonini qanday hisoblash mumkin?
$array.Count

PowerShell bilan bir massivini boshqa massiviga qanday qushilish mumkin?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

PowerShell bilan massividagi dublikatlarini qanday topish mumkin?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

PowerShell bilan massivdan dublikatlarini qanday olib tashlash mumkin?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

PowerShell bilan prefiks (“user01”, “user02”, … “user10”) bilan boshlanadigan ob’ektlarini qanday yaratish mumkin?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

PowerShell bilan AD Foydalanuvchining ACLini qanday ro’yxatga chiqarish mumkin?
(Get-Acl -Path "AD:\$dn").Access

PowerShell bilan bir jildning ACLlarini qanday ro’yxatga chiqarish mumkin?
(Get-Acl -Path C:\scripts).Access

PowerShell bilan AD Foydalanuvchining maxsus ACL ruxsat satrlarini (foydalanuvchilar yoki guruhlar uchun) qanday ro’yxatga chiqarish mumkin?

Up


Variables

PowerShell bilan eng keng tarqalgan ma’lumotlar turlari qaysilar?

PowerShell bilan ba’zi turi o’zgaruvchilar uchun minimal va maksimal qiymatlarni qanday topish mumkin?

PowerShell bilan ma’lumotlarni turi qanday sinash mumkin?

PowerShell bilan bir yerda-satr o’zgaruvchini qanday yaratish mumkin?

PowerShell bilan o’zgaruvchini qanday yaratish mumkin?
$powershellGuru = 'Hello'

PowerShell bilan doimiy o’zgarmaydigan o’zgaruvchini qanday yaratish mumkin?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

PowerShell bilan global o’zgaruvchini qanday yaratish mumkin?
$Global:powershellGuru = 'Hello' # Note : creating global variables is not recommended

PowerShell bilan bir o’zgaruvchini qanday o’qish mumkin?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

PowerShell bilan bir o’zgaruvchining turini qanday tekshirish mumkin?
$powershellGuru.GetType()

PowerShell bilan global doirasida o’zgaruvchilarni qanday topish mumkin?
Get-Variable -Scope Global

PowerShell bilan maxsus o’zgaruvchilarni nomi bilan qanday olish mumkin?
Get-Variable -Include *Preference -Exclude W*

PowerShell bilan bir o’zgaruvchiga ma’lum bir ma’lumot turini qanday tayinlash mumkin?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

PowerShell bilan bir xil qiymatiga ega bir necha o’zgaruvchilar qanday ishga tushirish mumkin?
$a = $b = $c = $d = $e = 0

PowerShell bilan o’zgaruvchining “$ _” mumkin boshqacha nomi nima?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

PowerShell bilan nomi “count” bilan boshlanadigan o’zgaruvchilarni qanday olib tashlash mumkin?
Remove-Variable -Name count*

PowerShell bilan mahalliy atrof- o’zgaruvchilarni qanday olish mumkin?
Get-ChildItem -Path Env:

PowerShell satr bilan atrof- o’zgaruvchining satrni qanday olish mumkin?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

PowerShell bilan atrof- o’zgaruvchi yo’liga yangi yo’lini (Masalan, C:\SysinternalsSuite) qanday kiritish mumkin?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

PowerShell bilan o’zgaruvchilarni qanday bog’lash mumkin?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

PowerShell bilan ErrorVariable o’zgaruvchini qanday foydalanish kerak?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

PowerShell bilan “Option Explicit” tengini (VBScript: o’zgaruvchining e’lon qilinishi talab qiladi) qanday yoqish / o’chirish mumkin?

Up


Static .NET Methods

PowerShell bilan statik a’zolarini qanday olish mumkin?
[DateTime] | Get-Member -Static

Up


Sounds

PowerShell bilan “signal” ovozini qanday ijro etish mumkin?
[System.Console]::Beep()

PowerShell bilan “yulduzcha” ovozini qanday ijro etish mumkin?
[System.Media.SystemSounds]::Asterisk.Play()

PowerShell bilan “xitob” ovozini qanday ijro etish mumkin?
[System.Media.SystemSounds]::Exclamation.Play()

PowerShell bilan Qanday mavjud tovushlarni olish mumkin?
[System.Media.SystemSounds] | Get-Member -Static

PowerShell bilan Qanday “WAV” tovushlarni qanday ijro etish mumkin?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
yoki
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

PowerShell bilan nutq yozilgan matnni qanday faollashtirish mumkin?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

PowerShell bilan XML faylni qanday o’qish mumkin?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

PowerShell bilan ma’lumotlarni XML fayli sifatida qanday eksport qilish mumkin?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

PowerShell bilan CLIXML faylidan ma’lumotlarni qanday import qilish mumkin?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

PowerShell bilan oddiy GUI (Windows formasi) qanday yaratish mumkin?

Up