FAQ POWERSHELL MU CHICHEWA

By | May 24, 2015


beta-v2-0


Concept : Anthu amakonda kufunsa za Powershell.

Mungagwiritsire ntchito ndandanda zosiyanasiyana :

  • Kutengera / phala malamulo kukhala ndi zilembo
  • Kuona msanga ndi malembedwe a inayake lamulo
  • Kupita patsogolo luso chidziwitso
  • Kupeza malamulo atsopano
  • Kukonzekera ntchito kuyankhulana

Kusinthidwa
July 02, 2015
Author Steve Renard
Gwero chichewa.powershell-guru.com
Categories
75
Mafunso
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
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
Windows10
Windows 2012
Windows Azure
Windows Forms
WMI
XML

System

Kodi kudziwa wanga Baibulo la PowerShell?

Kodi kuthamanga PowerShell mu lina lomwe chifukwa m’mbuyo ngakhale?
powershell.exe -Version 2.0

Kodi kumafunsa ndi kochepa PowerShell Baibulo (3.0 ndi apamwamba) mu ndi zilembo ndi PowerShell?
#Requires -Version 3.0

Kodi kumafunsa utsogoleri maudindo kwa ndi zilembo ndi PowerShell?

Kodi kufufuza magawo a ndi zilembo ndi PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Kodi kudziwa kuti panopa user ndi PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Kodi kulenga, Sinthani, ndi katundu mbiri ndi PowerShell?

Kodi kuchita kaye 5 masekondi / maminiti mu ndi zilembo ndi PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Kodi kuti otsiriza jombo ndi PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Kodi kuti mtundu accelerators ndi PowerShell?

Kodi kuti atchule oyambitsa mapulogalamu ndi PowerShell?

Mmene yochotsa yofunsira ndi PowerShell?

Kodi kutenga chithunzi lonse kompyuta kapena achangu. window ndi PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Kodi kuti uthenga kuwerengedwa kwa MSMQ queues ndi PowerShell?

Kodi kukhazikitsa ndondomeko kuphedwa ndi PowerShell?

Mmene kulenga Simungachite ndi PowerShell?

Kodi kulasa kapena unpin pulogalamu ya taskbar ndi PowerShell?

Kodi kutsegula Windows Explorer ndi PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Kodi anatchula chipangizo madalaivala ndi PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Mmene kulenga GUID ndi PowerShell?

Kodi kupeza malo zosakhalitsa chikwatu chifukwa panopa user ndi PowerShell?
[System.IO.Path]::GetTempPath()

Kodi kulumikizana njira ndi mwana njira mmodzi limodzi ndi njira PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Kodi kutchula zinthu zonse cmdlets “weni-” ndi PowerShell?
Get-Command -Verb Get

Kodi anatchula wapadera dongosolo zikwatu ndi PowerShell?

Kodi kukwera ISO / VHD mafaelo ndi PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Kodi kufufuza .NET M’chilamulo Mabaibulo anaika ndi PowerShell?

Kodi kuonanso ngati .NET M’chilamulo Baibulo 4.5 waikidwa ndi PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Kodi kuyamba ndi kuimitsa mawu olembedwa (kulenga mbiri ya Windows PowerShell gawoli) ndi PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Kodi kusintha panopa chikwatu kuti malo ndi PowerShell?
Set-Location -Path 'C:\scripts'

Kodi azichotsa nsalu yotchinga ndi PowerShell?
Clear-Host
cls # Alias

Kodi kusintha kuwonetsera kusamvana ndi PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Kodi kukhazikitsa “kudzaza zenera” window ndi PowerShell?
mode.com 300

Kodi kuti miyeso (m’lifupi ndi kukwera) la zithunzi ndi PowerShell?

Kodi kuwatenga Windows mankhwala ofunika ndi PowerShell?

Perfmon

Bwanji kufika pano “% purosesa Time” (pafupifupi) lomaliza 5 masekondi (10 Nthawi) ndi PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Kodi kutsegula ikuluikulu ndi PowerShell?

Kodi kufufuza panopa .NET ikuluikulu yodzaza ndi PowerShell?

Kodi kupeza GAC ​​(Global Assembly posungira) Njira ndi PowerShell?

Clipboard

Kodi kutengera zotsatira kwa zomatula ndi PowerShell?

Kodi kupeza zomwe zili mu zomatula ndi PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Kodi kuwatenga hotfixes anaika ndi PowerShell?
Get-HotFix -ComputerName $computer

Kodi kuwatenga hotfixes anaika pamaso / pambuyo tsiku lenileni ndi 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

Kodi kuonanso ngati hotfix waikidwa ndi PowerShell?
Get-HotFix -Id KB2965142

Kodi kuwatenga hotfixes anaika kutali kompyuta ndi PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Kodi kuti Pagefile nkhani PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Kodi kuwatenga analimbikitsa kukula (MB) kwa Pagefile ndi PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Mmene kulenga Pagefile (4096 MB) pa (D 🙂 galimoto ndi PowerShell?

Kodi ku chotsa ndi Pagefile pa (C 🙂 galimoto ndi PowerShell?

Maintenance

Kodi kufufuza kugawikana ndi galimoto ndi PowerShell?

Kodi kufufuza litayamba danga la wouluka ndi PowerShell?

Up


Files

Kodi kutsegula wapamwamba ndi PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Kodi kuwerenga wapamwamba ndi PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Kodi kulemba linanena bungwe ndi wapamwamba ndi PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Kodi kuwatenga fullname watsopano ndi zilembo wapamwamba ndi PowerShell?
$MyInvocation.MyCommand.Path

Mmene compress / zipi mafaelo ndi PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Mmene uncompress / unzip mafaelo ndi PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Kodi kuona mafaelo mu zip ankasungiramo ndi PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Kodi kusonyeza kukula kwa wapamwamba mu KB ndi PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Kodi kupeza mafaelo zazikulu zosakwana 1 GB ndi PowerShell?

Kodi kusonyeza dzina la wapamwamba popanda kutambasuka ndi PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Kodi kusonyeza ukugwirizana ndi wapamwamba ndi PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Kodi kuwatenga wapamwamba Baibulo la wapamwamba ndi PowerShell?

Kodi kuwatenga hasi wa wapamwamba ndi PowerShell?
(Get-FileHash $file).Hash

Kodi kuwatenga MD5 / SHA1 checksum wa wapamwamba ndi PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Kodi kusonyeza chobisika mafaelo ndi PowerShell?

Kodi kuonanso ngati wapamwamba ali mbali ndi PowerShell?

Mmene anapereka wapamwamba monga “Werengani Only” ndi PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Kodi kusintha “LastWriteTime” chikhumbo kwa sabata yatha kwa wapamwamba ndi PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Kodi kulenga latsopano wapamwamba ndi PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Mmene rename ndi wapamwamba ndi PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Mmene mtokoma / mtanda rename angapo mafaelo ndi PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Kodi ku chotsa ndi wapamwamba ndi PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Kodi kusonyeza 10 atsopano a munthu wapamwamba ndi PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Mmene unblock angapo mafaelo a mchikwatu ndi PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Kodi kuchotsa chopanda mizere ku wapamwamba ndi PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Kodi kuonanso ngati wapamwamba aliko ndi PowerShell?

Kodi kuti zatsopano / wamkulu analenga wapamwamba mu mchikwatu ndi PowerShell?

Kodi kuchotsa chibwereza mizere ku wapamwamba ndi PowerShell?

Bwanji kufika owona analenga kwambiri kapena zosakwana 1 mwezi wa mchikwatu ndi PowerShell?

Bwanji kufika owona analenga kwambiri kapena zosakwana 1 chaka mu mchikwatu ndi PowerShell?

Bwanji za katundu phindu la variable ndi wapamwamba ndi PowerShell?
Set-Content -Path file.txt -Value $variable

Mmene awerenge chiwerengero cha owona (* .txt) mu mchikwatu ndi PowerShell?

Kodi kufufuza chingwe mkati angapo mafaelo ndi PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

Kodi kusonyeza woyamba / otsiriza mzere wa wapamwamba ndi PowerShell?

Kodi kusonyeza inayake mzere chiwerengero cha wapamwamba ndi PowerShell?

Mmene awerenge chiwerengero cha mizere ya wapamwamba ndi PowerShell?

Mmene awerenge chiwerengero cha anthu otchulidwa ndi mawu a wapamwamba ndi PowerShell?

Kodi download ndi wapamwamba ndi PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Kodi kusonyeza utumiki njira ya wapamwamba ndi PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Kodi kuwonera wina wapamwamba ku mchikwatu ndi PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Kodi kuwonera wina fayilo angapo zikwatu ndi PowerShell?

Kodi kutengera angapo mafaelo wina mchikwatu ndi 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

Kodi kupeza Global Catalog maseva mu Amalalikira Directory ndi PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Kodi kupeza malo mu Amalalikira Directory ndi PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Kodi kupeza panopa ulamuliro controller ndi PowerShell?
(Get-ADDomainController).HostName

Kodi kupeza onse pa ulamuliro owongolera mu ufumuwo ndi PowerShell?

Kodi kupeza AD kugawanika zolephera ndi PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Kodi kupeza tombstone moyo kwa m’nkhalango Amalalikira Directory ndi PowerShell?

Kodi kupeza mfundo za nkhalango / ulamuliro mu Amalalikira Directory ndi PowerShell?

Kodi kutenga njira ya “asiye Zinthu” chidebe mu Amalalikira Directory ndi PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Mmene chimathandiza AD akonzanso nkhokwe Mbali Amalalikira Directory ndi PowerShell?

Mmene adzabwezeretsa AD Nkhani ku akonzanso nkhokwe mu Amalalikira Directory ndi PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Kodi kupeza FSMO maudindo ndi PowerShell?

Kodi kulumikiza inayake ulamuliro controller ndi PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Kodi kuti panopa logon seva ndi PowerShell?

Kodi kuchita “gpupdate” pa kompyuta ndi PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Kodi kulenga latsopano gulu Amalalikira Directory ndi PowerShell?

Kodi kuchotsa gulu Amalalikira Directory ndi PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Kodi ndiwonjezere akuwagwiritsa ntchito gulu Amalalikira Directory ndi PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Kodi kuchotsa user ku gulu Amalalikira Directory ndi PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Kodi kupeza chopanda magulu (popanda mamembala) mu Amalalikira Directory ndi PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Kodi kuwerenga chopanda magulu (popanda mamembala) mu Amalalikira Directory ndi PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Kodi kutenga ziwalo za gulu Amalalikira Directory ndi PowerShell?

Kodi kutenga ziwalo za gulu ndi recursive ziwalo Amalalikira Directory ndi PowerShell?

Mmene awerenge chiwerengero cha anthu a gulu / popanda recursive ziwalo Amalalikira Directory ndi PowerShell?

Users

Mmene Tingagwiritsire ntchito wildcard mu fyuluta ya “Pita-ADUser” mu Amalalikira Directory ndi PowerShell?

Kodi chosuntha user wina OU mu Amalalikira Directory ndi PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Kodi kupeza onse Anthu amene ali (zinapeza malo okhala) kwa user ndi PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Kodi kuwatenga Nthambi (chidule dzina / truncated) kwa user ndi PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Mmene rename Dzina (FullName), (DisplayName), GivenName (FirstName), ndi dzina (LastName) kwa user nkhani Amalalikira Directory ndi PowerShell?

Kodi kusintha Kufotokozera, Office, ndi nambala ya telefoni user nkhani Amalalikira Directory ndi PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Kodi kuika atapita tsiku “31/12/2015” kapena “Palibe” kwa user nkhani Amalalikira Directory ndi PowerShell?

Mmene tidziwe ndi user nkhani Amalalikira Directory ndi PowerShell?
Unlock-ADAccount $samAccountName

Kodi powukitsidwa / zongolimbana ndi user nkhani Amalalikira Directory ndi PowerShell?

Kodi kuchotsa user nkhani Amalalikira Directory ndi PowerShell?
Remove-ADUser $samAccountName

Mmene bwererani ndi pazinthu wina user nkhani Amalalikira Directory ndi PowerShell?

Mmene bwererani ndi pazinthu zingapo user nkhani (mtokoma) mu Amalalikira Directory ndi PowerShell?

Kodi kupeza mwiniwake wa wapamwamba mu Amalalikira Directory ndi PowerShell?

Kodi kupeza OU (Gulu Unit) kwa user mu Amalalikira Directory ndi PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Kodi kupeza olumala user nkhani Amalalikira Directory ndi PowerShell?

Kodi kupeza n’kumwalira user nkhani Amalalikira Directory ndi PowerShell?
Search-ADAccount -AccountExpired

Kodi kupeza zokhoma user nkhani Amalalikira Directory ndi PowerShell?
Search-ADAccount -LockedOut

Kodi kupeza SID wa user nkhani Amalalikira Directory ndi PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Kodi kutembenuza dzina lolowera ku SID mu Amalalikira Directory ndi PowerShell?

Kodi kutembenuka ndi SID kuti lolowera ku Amalalikira Directory ndi PowerShell?

Mmene anagawa wolemekezeka Dzina la user nkhani Amalalikira Directory ndi PowerShell?

Kodi kupeza tsiku la chilengedwe / kusinthidwa kwa user nkhani Amalalikira Directory ndi PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Kodi kusonyeza pompa ndi mandatory katundu kalasi “Zopanga” mu Amalalikira Directory ndi PowerShell?

Kodi kuwatenga LDAP njira kwa user mu Amalalikira Directory ndi PowerShell?

Kodi kusintha CN (Kusiyana Name) kwa user mu Amalalikira Directory ndi PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

Kodi kuwatenga Gulu Unit (OU) kholo la user mu Amalalikira Directory ndi PowerShell?

Kodi kupeza mwiniwake wa user (amene analenga chifukwa) mu Amalalikira Directory ndi PowerShell?

Kodi anthu onse apadziko PwdLastSet chikhumbo kwa user mu Amalalikira Directory ndi PowerShell?

Computers

Kodi kuyesa otetezeka njira pakati pa m’dera kompyuta ndi ulamuliro ndi PowerShell?
Test-ComputerSecureChannel

Kodi kukonzanso otetezeka njira pakati pa m’dera kompyuta ndi ulamuliro ndi PowerShell?
Test-ComputerSecureChannel -Repair

Mmene zongolimbana kompyuta nkhani Amalalikira Directory ndi PowerShell?
Disable-ADAccount $computer

Kodi kupeza makompyuta zapadera Pulogalamu KA mu Amalalikira Directory ndi PowerShell?

Organizational Unit (OU)

Mmene amalola Gulu Unit (OU) mu Amalalikira Directory ndi PowerShell?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

Kodi kupeza Gulu Unit (OU) Nkhani Amalalikira Directory ndi PowerShell?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

Kodi kusintha malongosoledwe a Gulu Unit (OU) mu Amalalikira Directory ndi PowerShell?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

Kodi powukitsidwa / zongolimbana ndi Gulu Unit (OU) kuchokera mwangozi kufufutidwa mu Amalalikira Directory ndi PowerShell?

Mmene chimathandiza mwangozi kufufutidwa onse Gulu Unit (OU) mu Amalalikira Directory ndi PowerShell?

Kodi ku chotsa ndi Gulu Unit (OU) otetezedwa ku mwangozi kufufutidwa mu Amalalikira Directory ndi PowerShell?

Kodi kutembenuza lodziwika Dzina la Gulu Unit (OU) kuti Kusiyana Dzina Amalalikira Directory ndi PowerShell?

Kodi kutchula zinthu zopanda Gulu mayunitsi (neyi) ndi PowerShell?

Kodi kuti manenjala wa gulu ndi PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Kodi mutenge ndi IP adiresi v4 (80.80.228.8) ndi Regex ndi 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

Kodi mutenge ndi Mac adiresi (C0-D9-62-39-61-2D) ndi olekanitsa “-” ndi Regex ndi 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

Kodi mutenge ndi Mac adiresi (C0: D9: 62: 39: 61: 2D) ndi olekanitsa “:” ndi Regex ndi 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

Kodi mutenge tsiku (10/02/2015) ndi Regex ndi PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Kodi mutenge ulalo (www.powershell-guru.com) ndi Regex ndi PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Kodi mutenge imelo (user@domain.com) ndi Regex ndi 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

Kodi mutenge “Guru” pa chingwe chitsanzo ndi Regex ndi PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Kodi mutenge “guru.com” pa chingwe chitsanzo ndi Regex ndi PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Kodi mutenge “powershell-guru.com” pa chingwe chitsanzo ndi Regex ndi PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Kodi mutenge “123” pa chingwe chitsanzo ndi Regex ndi PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Kodi mutenge “$” (dola chizindikiro) kwa chingwe chitsanzo ndi Regex ndi PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Kodi m’malo chikhalidwe (* .com) ndi mzake (* .fr) mu chingwe ndi Regex ndi PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Kodi kuthawa chingwe ndi Regex ndi PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Kodi kukakamiza gulu la pamtima ndi zinyalala msonkho ndi PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Kodi kuwatenga RAM kukula kwa kompyuta ndi PowerShell?

Up


Date

Kodi kuti panopa tsiku ndi PowerShell?
Get-Date
[Datetime]::Now

Kodi kusonyeza tsiku zosiyanasiyana Chiurdu ndi PowerShell?

Kodi kutembenuza tsiku (Datetime) kuti tsiku (chingwe) ndi PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

Kodi kutembenuza tsiku (chingwe) kuti tsiku (Datetime) ndi PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Kodi kudziwa kusiyana (chiwerengero cha masiku, maola, mphindi, kapena masekondi) pakati pa masiku ndi 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

Kodi kuyerekeza awiri madeti ndi 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

Kodi kwa mafomu osiyanasiyana masiku “Datetime” ndi PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Kodi kuyamba ndi kusiya wotchi yoyimitsa ndi PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Kodi kuti panopa tsiku la sabata ndi PowerShell?
(Get-Date).DayOfWeek #Sunday

Kodi kuti dzulo a tsiku ndi PowerShell?
(Get-Date).AddDays(-1)

Kodi kuti chiwerengero cha masiku mu mwezi (mu February 2015) ndi PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Kodi kudziwa adzatumpha chaka ndi PowerShell?
[DateTime]::IsLeapYear(2015)

Kodi anatchula nthawi n’kupita ndi PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Mmene encode (kuti ASCII mtundu) ndi decode ulalo ndi PowerShell?

Kodi zofanana ndi za ku Intaneti malamulo ndi PowerShell?

Kodi kuti IP maadiresi ndi PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Mmene zongolimbana IP adiresi v6 (IPv6) ndi PowerShell?

Mmene tsimikizira ndi IP adiresi v4 (IPv4) ndi PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Kodi kupeza kunja IP adiresi ndi PowerShell?

Kodi kupeza Hostname ku IP adiresi ndi PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Kodi kupeza IP adiresi ku Hostname ndi PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Kodi kupeza FQDN ku Hostname ndi PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Kodi kupeza maukonde kasinthidwe (IP, Subnet, Polakwika, ndi DNS) ndi PowerShell?

Kodi kupeza Mac adiresi ndi PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Mmene ping kompyuta ndi PowerShell?

Kodi kufufuza ngati muli kompyuta kugwiritsa ntchito intaneti ndi PowerShell?

Kodi kuchita “Whois” osakira kwa webusaiti ndi PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Kodi kupeza mfundo ya pagulu IP (Geolocation) ndi PowerShell?

Kodi kufufuza ngati doko ndi lotseguka / kutsekedwa ndi PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Kodi kuchita “tracert” ndi PowerShell?
Test-NetConnection www.google.com -TraceRoute

Kodi kukonza nyumba Intaneti chokhudza mbiri ndi PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Kodi kusonyeza TCP doko kugwirizana ndi PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Kodi zochepetsa yaitali URL mu kakang’ono URL ndi PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Kodi kuti lochitira voti zoikamo ndi PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Kodi kufufuza DNS posungira pa wamba kompyuta ndi PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Kodi kuzindikira bwino ndi DNS posungira pa wamba kompyuta ndi PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Kodi kuzindikira bwino ndi DNS posungira zakutali makompyuta ndi PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Kodi kuwerenga makamu kupala ndi PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Mmene kupanga ndi mwachisawawa achinsinsi ndi PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Kodi kusintha komweko pazinthu munthu waudindo kutali seva ndi PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Kodi kupeza achinsinsi lothera ntchito za nkhani Amalalikira Directory ndi PowerShell?

Up


Printers

Kodi kutchula zinthu zonse makinawo chapadera seva ndi PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Kodi kutchula zinthu zonse madoko chapadera seva ndi PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Kodi kusintha ndemanga / malo yosindikiza mabuku ndi PowerShell?

Kodi kuyeretsa (kuletsa ntchito zonse) kwa yosindikiza mabuku ndi PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Kodi kusindikiza mayeso tsamba yosindikiza mabuku ndi PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Kodi kuti kusindikiza queues kwa osindikiza mabuku ndi PowerShell?

Up


Regedit

Read

Kodi anatchula kaundula ming’oma PowerShell?
Get-ChildItem -Path Registry::

Kodi kuti kaundula mfundo ndi phindu mitundu ndi PowerShell?

Kodi anatchula mfundo kaundula subkeys ndi PowerShell?

Kodi anatchula mfundo kaundula subkeys mu recursive njira PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Kodi kupeza subkeys ndi nkhani inayake dzina PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Kodi kubwerera kokha dzina la kaundula subkeys ndi PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Kodi anatchula kaundula mfundo ndi PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Kodi kuwerenga inayake kaundula mtengo wapatali PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Kodi kuwerenga inayake kaundula mtengo kutali kompyuta ndi PowerShell?

Write

Kodi kulenga latsopano kaundula mfundo ndi PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Kodi kulenga mu kaundula mtengo wapatali PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Kodi kusintha ndi alipo kaundula mtengo wapatali PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Kodi ku chotsa mu kaundula mtengo wapatali PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Kodi ku chotsa mu kaundula mfundo ndi PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Kodi kuyesa ngati kaundula mfundo aliko ndi PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Kodi kuyesa ngati kaundula mtengo aliko ndi PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Kodi kuchotsa zoyera malo otchulidwa kuyambira chiyambi cha chingwe ndi PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Kodi kuchotsa zoyera malo otchulidwa pa mapeto a chingwe ndi PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Kodi kuchotsa zoyera malo otchulidwa (kuyambira mpaka) a chingwe ndi PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Kodi kutembenuza chingwe ku chapamwamba zinachitikira PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Kodi kutembenuza chingwe kupeputsa zinachitikira PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Kodi kusankha substring “PowerShell” za zingwe “PowerShellGuru” ndi PowerShell?
$string.Substring(0,10)

Kodi kusankha substring “Guru” za zingwe “PowerShellGuru” ndi PowerShell?
$string.Substring(10)

Kodi kusankha nambala “123” la “PowerShell123Guru” ndi PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Kodi kuwatenga ziro ofotokoza Mndandanda wa “Guru” za zingwe “PowerShellGuru” ndi PowerShell?
$string.IndexOf('Guru') # 10

Kodi kufufuza ngati chingwe ndi null kapena chopanda ndi PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Kodi kufufuza ngati chingwe ndi null, zopanda kanthu, kapena lili zokha zoyera malo otchulidwa ndi PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Kodi kufufuza ngati chingwe lili inayake kalata ndi PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Kodi kubwerera kutalika kwa chingwe ndi PowerShell?
$string.Length

Mmene concatenate awiri zingwe ndi PowerShell?

Kodi yagwirizana chimodzi kapena zingapo m’mabokosi “[]” mu chingwe ndi PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Kodi yagwirizana chimodzi kapena zingapo parentheses “()” mu chingwe ndi PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Kodi yagwirizana chimodzi kapena zingapo lopiringizika m’mabokosi “{}” mu chingwe ndi PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Kodi yagwirizana chimodzi kapena zingapo njingayo m’mabokosi “<>” mu chingwe ndi PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Kodi yagwirizana aliyense lowercase makalata (ma ABC) mu chingwe ndi PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Kodi yagwirizana aliyense upperletters (ABC) mu chingwe ndi PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Kodi yagwirizana “[tsa” (p m’munsi mlandu) mu chingwe ndi PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Kodi yagwirizana “[P” (P chapamwamba mlandu) mu chingwe ndi PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Kodi m’malo mzere ndi mzere wina ndi PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Kodi kutembenuza kugawanika opaleshoni chingwe (kuchuluka) ndi PowerShell?
(1/2).ToString('P')

Kodi kwa mafomu zingwe munali manambala ndi PowerShell?

Kodi kusankha mawu otsiriza a chiganizo ndi PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

Kodi kuti yaikulu kwambiri mawu a chiganizo ndi PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

Mmene awerenge chiwerengero cha nthawi chingwe alipo m’sentensi ndi PowerShell?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

Kodi kutengera aliyense khalidwe chingwe ku khalidwe lomenyera ndi PowerShell?

Kodi kutembenuza kalata yoyamba kwa uppercase a chingwe ndi PowerShell?

Mmene PAD (kumanja kapena kumanzere) chingwe ndi PowerShell?

Mmene encode ndi decode chingwe ku Base64 ndi PowerShell?

Kodi kutembenuza chiwerengero (kuti ndi) bayinare ndi PowerShell?

Kodi kubwerera okha otsiriza kholo mchikwatu mu njira ndi PowerShell?

Kodi kubwerera okha otsiriza katunduyo mu njira ndi PowerShell?

Up


Math

Kodi anatchula njira ya System.Math kalasi ndi PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Kodi kubwerera mtheradi mtengo wapatali PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Kodi kubwerera mbali amene sine ndi chinaneneratu number ndi PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Kodi kubwerera denga mtengo wapatali PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Kodi kubwerera pansi mtengo wapatali PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Kodi kubwerera zachilengedwe (m’munsi e) logarithm wa inayake number ndi PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

Kodi kubwerera m’munsi 10 logarithm wa inayake number ndi PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

Kodi kubwerera ku pazipita awiri mfundo ndi PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Kodi kubwerera ku osachepera awiri mfundo ndi PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Kodi kubwerera angapo anamuukitsa kwa inayake mphamvu ndi PowerShell?
[Math]::Pow(2,4) #Returns 16

Kodi kubwerera ndi decimal mtengo yapafupi yofunika mtengo wapatali PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Kodi kubwerera ku mbali ya inayake decimal number ndi PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Kodi kubwerera m’bwalo muzu wa inayake number ndi PowerShell?
[Math]::Sqrt(16) #Returns 4

Kodi kubwerera ku PI zonse ndi PowerShell?
[Math]::Pi #Returns 3,14159265358979

Kodi kubwerera zachilengedwe logarithmic m’munsi (zonse e) ndi PowerShell?
[Math]::E #Returns 2,71828182845905

Kodi kufufuza ngati nambala ngakhale kapena osamvetseka ndi PowerShell?
[bool]($number%2)

Up


Hashtables

Kodi kulenga chopanda kanthu hashtable ndi PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Mmene kulenga hashtable ndi zinthu ndi PowerShell?

Mmene kulenga hashtable kosanjidwa ndi mfundo / dzina (analamula dikishonale) ndi zinthu ndi PowerShell?

Kodi kuwonjezera zinthu (kiyi-mtengo awiri) kuti hashtable ndi PowerShell?
$hashtable.Add('Key3', 'Value3')

Kodi kupeza zenizeni kufunika kwa hashtable ndi PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Kodi kuwatenga osachepera kufunika kwa hashtable ndi PowerShell?

Kodi kuwatenga pazipita kufunika kwa hashtable ndi PowerShell?

Kodi kusintha zinthu mu hashtable ndi PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Kodi kuchotsa zinthu mu hashtable ndi PowerShell?
$hashtable.Remove('Key1')

Kodi kuzindikira bwino ndi hashtable ndi PowerShell?
$hashtable.Clear()

Kodi kufufuza pamaso enieni ofunika / phindu mu hashtable ndi PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Kodi kwa mafomu ndi mfundo / phindu mu hashtable ndi PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Kodi kulenga chopanda kanthu lomenyera ndi PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Kodi kulenga osiyanasiyana ndi zinthu ndi PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Kodi kuwonjezera zinthu ku osiyanasiyana ndi PowerShell?
$array += 'D'
[void]$array.Add('D')

Kodi kusintha tili mu osiyanasiyana ndi PowerShell?
$array[0] = 'Z' # 1st item[0]

Kodi kufufuza kukula osiyanasiyana ndi PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Kodi kuti akatenge katundu wina / angapo / zinthu zonse mu osiyanasiyana ndi PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Kodi kuchotsa chopanda zinthuzi osiyanasiyana ndi PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Kodi kufufuza ngati tili alipo mu osiyanasiyana ndi PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Kodi kupeza zosonyezera ambiri tili mu osiyanasiyana ndi PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Kodi kuthetsa dongosolo la zinthu mu osiyanasiyana ndi PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Mmene kupanga ndi mwachisawawa Chinthu osiyanasiyana ndi PowerShell?
$array | Get-Random

Kodi kwa mafomu osiyanasiyana mu akwera / kutsika njira PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Mmene awerenge chiwerengero cha zinthuzi osiyanasiyana ndi PowerShell?
$array.Count

Kodi kuwonjezera osiyanasiyana kwa wina ndi PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Kodi kupeza Zobwerezedwa ku osiyanasiyana ndi PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Kodi kuchotsa Zobwerezedwa ku osiyanasiyana ndi PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Kodi kulenga osiyanasiyana ndi zinthu Tiyamba ndi prefix (“user01”, “user02”, … “user10”) ndi PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Kodi anatchula ACL cha AD user ndi PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Kodi anatchula ACL wa mchikwatu ndi PowerShell?
(Get-Acl -Path C:\scripts).Access

Kodi kutchula zinthu zapadera ACL chilolezo zolemba (amagwiritsa ntchito kapena magulu) wa AD user ndi PowerShell?

Up


Variables

Kodi ambiri deta mitundu ndi PowerShell?

Kodi kupeza osachepera ndi pazipita mfundo kwa mtundu zosintha ndi PowerShell?

Kodi kuyesa datatype ndi PowerShell?

Mmene kulenga Apa-chingwe variable ndi PowerShell?

Mmene kulenga variable ndi PowerShell?
$powershellGuru = 'Hello'

Kodi analenga zonse variable ndi PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Kodi analenga padziko lonse variable ndi PowerShell?
$Global:powershellGuru = 'Hello'

Kodi kuwerenga variable ndi PowerShell?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

Kodi kufufuza mtundu wa variable ndi PowerShell?
$powershellGuru.GetType()

Kodi kupeza zosintha mu lonse kuchuluka ndi PowerShell?
Get-Variable -Scope Global

Kodi kupeza zenizeni zosintha dzina lake ndi PowerShell?
Get-Variable -Include *Preference -Exclude W*

Momwe ntchito inayake deta mtundu ku variable ndi PowerShell?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

Mmene initialize angapo zosintha amodzi mtengo wapatali PowerShell?
$a = $b = $c = $d = $e = 0

Kodi yemwenso ankatchedwa kuti variable “$ _” ndi PowerShell?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

Kodi kuchotsa zosintha ndi dzina kuyambira “kuwerenga” ndi PowerShell?
Remove-Variable -Name count*

Kodi kuti m’deralo chilengedwe zosintha ndi PowerShell?
Get-ChildItem -Path Env:

Kodi kuti M’njira Environmental Variable mzere ndi mzere ndi PowerShell?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

Kodi kuwonjezera latsopano njira (wakale. C: \ SysinternalsSuite) kuti M’njira Environmental Variable ndi PowerShell?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

Mmene concatenate zosintha ndi PowerShell?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

Kodi ntchito ErrorVariable ndi PowerShell?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

Kodi powukitsidwa / zongolimbana wofanana “yankho zolaula” (VBScript: amafuna kuti variable lilengezedwe) ndi PowerShell?

Up


Static .NET Methods

Kodi kupeza malo amodzi anthu ndi PowerShell?
[DateTime] | Get-Member -Static

Up


Sounds

Kodi kuimba “beep” mawu ndi PowerShell?
[System.Console]::Beep()

Kodi kuimba “asterisk” mawu ndi PowerShell?
[System.Media.SystemSounds]::Asterisk.Play()

Kodi kuimba “mawu akuti” mawu ndi PowerShell?
[System.Media.SystemSounds]::Exclamation.Play()

Kodi kuti alipo phokoso ndi PowerShell?
[System.Media.SystemSounds] | Get-Member -Static

Kodi kusewera “WAV” zikumveka ndi PowerShell?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
kapena
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

Mmene yambitsa mawu olembedwa lemba PowerShell?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

Kodi kuwerenga ndi XML wapamwamba ndi PowerShell?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

Bwanji za katundu deta monga XML wapamwamba ndi PowerShell?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

Kodi zofunika kafukufuku wa CLIXML wapamwamba ndi PowerShell?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

Kodi kulenga mfundo GUI (Windows Fomu) ndi PowerShell?

Up


Characters

Kodi anthu onse apadziko ASCII kufunika kwa chikhalidwe ndi PowerShell?
[char]64

Kodi kutembenuza khalidwe kwa ASCII mtengo wapatali PowerShell?
[int][char]'@'

Mmene kupanga ya English zilembo ndi PowerShell?
[char[]](97..122)

Up


Compare

Kodi kuyerekeza awiri magulu ndi PowerShell?

Kodi kuyerekeza awiri njira ndi PowerShell?

Up


Microsoft Exchange

Mmene akatenge mndandanda wa pafoni zipangizo maloboti ndi ogwiritsa ‘olandirira makalata ndi PowerShell?
Get-ActiveSyncDeviceStatistics

Kodi kuwonjezera “Full zokhudza” zilolezo kwa bokosi la makalata kwa user ndi PowerShell?
Add-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess'

Kodi kuchotsa “Full zokhudza” zilolezo kwa bokosi la makalata kwa user ndi PowerShell?
Remove-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess' -InheritanceType 'All'

Kodi kuwonjezera “Lola Monga” zilolezo kwa bokosi la makalata kwa user ndi PowerShell?
Add-ADPermission -Identity $dn -User 'DOMAIN\powershellguru' -ExtendedRights 'Send-As'

Kodi kuchotsa “Lola Monga” zilolezo kwa bokosi la makalata kwa user ndi PowerShell?

Kodi kupeza Makalata Obwera malamulo ku bokosi la makalata ndi PowerShell?
Get-InboxRule -Mailbox 'Powershell.Guru'

Kodi kuwatenga SMTP potchula ogwiritsa amene OWA (maganizo Web zokhudza) chinathandiza ndi PowerShell?
Get-CASMailbox -Filter{OWAEnabled -eq $true} | Select-Object -Property Name, PrimarySMTPAddress

Exchange 2007

Kodi kukhazikitsa analipo requisites kwa seva Kusinthanitsa seva 2007 Hub Transport, bokosi la makalata (MBX), ndipo zikufuna zokhudza seva (CAS) ndi PowerShell?

Exchange 2010

Kodi kukhazikitsa analipo requisites kwa seva Kusinthanitsa seva 2010 Hub Transport, bokosi la makalata (MBX), ndipo zikufuna zokhudza seva (CAS) ndi PowerShell?

Exchange 2013

Kodi kukhazikitsa analipo requisites kwa seva Kusinthanitsa seva 2013 olandirira makalata (MBX) ndipo zikufuna zokhudza seva (CAS) ndi PowerShell?

Kodi kukhazikitsa analipo requisites kwa seva Kusinthanitsa seva 2013 zikufuna zokhudza seva (CAS) yekha ndi PowerShell?