MASWALI AMBAYO HUULIZWA KUHUSU POWERSHELL

By | May 17, 2015

translated-swahili


beta-v2-0


Dhana: Maswali ambayo huulizwa kuhusu POWERSHELL

Unaweza kutumia orodha hii kwa njia tofauti:

  • Kunakiri/kuweka amri katika script
  • Kuangalia haraka sintaksi ya amri maalum
  • Kuboresha maarifa yako kiufundi
  • Kugundua amri mpya
  • Kuandaa mahojiano ya kazi

Imesasishwa
2 Julai 2015
Mwandishi Steve Renard
Chanzo swahili.powershell-guru.com
Jamii
75
Maswali
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

Jinsi ya kuamua toleo langu la PowerShell?

Jinsi ya kuendesha PowerShell katika toleo lingine la utangamano nyuma?
powershell.exe -Version 2.0

Jinsi ya kuhitaji PowerShell toleo ndogo (3.0 na ya juu) katika script na PowerShell?
#Requires -Version 3.0

Jinsi ya kuhitaji marupurupu ya utawala kwa ajili ya script na PowerShell?

Jinsi ya kuangalia vigezo vya script na PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Jinsi ya kupata taarifa kwa mtumiaji wa sasa na PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Jinsi ya kuunda, kuhariri, na Reload hadhi na PowerShell?

Jinsi ya kufanya pause ya sekunde 5/dakika katika script na PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Jinsi ya kupata muda wa boot ya mwisho na PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Jinsi ya kupata aina za accelerators na PowerShell?

Jinsi ya kuorodhesha programu startup na PowerShell?

Jinsi ya kufuta programu na PowerShell?

Jinsi ya kuchukua screenshot ya desktop nzima au la dirisha kazi na PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Jinsi ya kuhesabu ujumbe kwa MSMQ foleni na PowerShell?

Jinsi ya kuweka sera utekelezaji na PowerShell?

Jinsi ya kujenga njia ya mkato na PowerShell?

Jinsi ya kubandika au kubandua programu wa taskbar na PowerShell?

Jinsi ya kufungua Windows Explorer na PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Jinsi ya kuorodhesha programu maalum na PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Jinsi ya kuunda GUID na PowerShell?

Jinsi ya kupata eneo la saraka la muda kwa mtumiaji wa sasa na PowerShell?
[System.IO.Path]::GetTempPath()

Jinsi ya kujiunga na njia na mtoto njia katika njia moja na PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Jinsi ya kuorodhesha yote cmdlets “Get- *” na PowerShell?
Get-Command -Verb Get

Jinsi ya kuorodhesha makabrasha maalum mfumo na PowerShell?

Jinsi ya kushikisha ISO mafaili/VHD na PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Jinsi ya kuangalia matoleo ya NET Framework imewekwa na PowerShell?

Jinsi ya kuangalia kama NET Framework 4.5 toleo imewekwa na PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Jinsi ya kuanza na kuacha nakala (kujenga rekodi ya kikao Windows PowerShell) na PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Jinsi ya kubadilisha directory ya sasa kwa eneo maalum na PowerShell?
Set-Location -Path 'C:\scripts'

Jinsi ya kufuta screen na PowerShell?
Clear-Host
cls # Alias

Jinsi ya kubadilisha kuonyesha azimio na PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Jinsi ya kuweka “screen kamili” dirisha na PowerShell?
mode.com 300

Jinsi ya kupata vipimo (upana na urefu) vya picha ya pamoja na PowerShell?

Jinsi ya kupata product key wa bidhaa na PowerShell?

Perfmon

Jinsi ya kupata “% Processor Muda” wa sasa (wastani) katika sekunde ya mwisho ya 5 (mara 10) na PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Jinsi ya kusheheni makanisa na PowerShell?

Jinsi ya kuangalia .NET assemblies kubeba na PowerShell?

Jinsi ya kupata GAC ​​(Global Bunge Cache) njia na PowerShell?

Clipboard

Jinsi ya kunakili matokeo na clipboard matokeo kwa PowerShell?

Jinsi ya kupata maudhui ya clipboard na PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Jinsi ya kupata hotfixes iliyowekwa na PowerShell?
Get-HotFix -ComputerName $computer

Jinsi ya kupata hotfixes imewekwa kabla/baada ya tarehe maalum na 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

Jinsi ya kuangalia kama hotfix imewekwa na PowerShell?
Get-HotFix -Id KB2965142

Jinsi ya kupata hotfixes iliyowekwa kwenye kompyuta kijijini na PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Jinsi ya kupata taarifa Pagefile na PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Jinsi ya kupata ukubwa uliopendekeza (MB) kwa ajili ya Pagefile na PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Jinsi ya kuunda Pagefile (4096 MB) juu ya (D 🙂 gari na PowerShell?

Jinsi ya kufuta Pagefile juu (C 🙂 gari na PowerShell?

Maintenance

Jinsi ya kuangalia mgawanyiko wa gari na PowerShell?

Jinsi ya kuangalia nafasi disk ya anatoa kwa PowerShell?

Up


Files

Jinsi ya kufungua faili na PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Jinsi ya kusoma faili na PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Jinsi ya kuandika pato na faili na PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Jinsi ya kupata majina kamili ya sasa script faili na PowerShell?
$MyInvocation.MyCommand.Path

Jinsi ya kusasisha faili na PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Jinsi ya kusasisha faili na PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Jinsi ya kuona faili katika archive ZIP pamoja PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Jinsi ya kuonyesha ukubwa wa faili katika KB pamoja PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Jinsi ya kupata faili kubwa au chini ya 1 GB kwa PowerShell?

Jinsi ya kuonyesha jina la faili bila ugani na PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Jinsi ya kuonyesha upanuzi wa faili na PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Jinsi ya kupata toleo la faili na PowerShell?

Jinsi ya kupata hash ya faili na PowerShell?
(Get-FileHash $file).Hash

Jinsi ya kupata MD5/SHA1 checksum ya faili na PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Jinsi ya kuonyesha faili za siri na PowerShell?

Jinsi ya kuangalia kama faili ana ugani na PowerShell?

Jinsi ya kuweka faili kama “Kusoma Tu” na PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Jinsi ya kubadili “LastWriteTime” sifa kwa wiki iliyopita kwa ajili ya faili na PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Jinsi ya kuunda faili mpya na PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Jinsi ya kubadili jina faili kwa PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Jinsi ya wingi/kundi rename faili nyingi na PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Jinsi ya kufuta faili na PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Jinsi ya kuonyesha 10 latest mistari ya faili na PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Jinsi ya kufungulia mafaili kadhaa ya kabrasha na PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Jinsi ya kuondoa mistari tupu kutoka faili na PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Jinsi ya kuangalia kama faili lipo na PowerShell?

Jinsi ya kupata newest/kongwe kuundwa faili katika kabrasha na PowerShell?

Jinsi ya kuondoa duplicate mistari kutoka faili na PowerShell?

Jinsi ya kupata mafaili kuundwa zaidi au chini ya 1 mwezi katika kabrasha na PowerShell?

Jinsi ya kupata mafaili kuundwa zaidi au chini ya 1 mwaka katika kabrasha na PowerShell?

Jinsi ya kuuza thamani ya kutofautiana na faili na PowerShell?
Set-Content -Path file.txt -Value $variable

Jinsi ya kuhesabu idadi ya mafaili (* txt) katika kabrasha na PowerShell?

Jinsi ya kutafuta majina katika faili nyingi na PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

Jinsi ya kuonyesha kwanza/mwisho mstari wa faili na PowerShell?

Jinsi ya kuonyesha maalum mstari idadi ya faili na PowerShell?

Jinsi ya kuhesabu idadi ya mistari ya faili na PowerShell?

Jinsi ya kuhesabu idadi ya wahusika na maneno ya faili na PowerShell?

Jinsi ya kushusha faili na PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Jinsi ya kuonyesha njia kamili ya faili na PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Jinsi ya kunakili faili moja kwa kabrasha na PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Jinsi ya kunakili faili moja kwa makabrasha nyingi na PowerShell?

Jinsi ya kunakili faili nyingi kwa kabrasha moja na 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

Jinsi ya kupata Global Catalog servrar katika Active Directory kwa PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Jinsi ya kupata maeneo katika Active Directory kwa PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Jinsi ya kupata sasa mtawala domain na PowerShell?
(Get-ADDomainController).HostName

Jinsi ya kupata controllers wote domain katika miliki na PowerShell?

Jinsi ya kupata kushindwa AD replication na PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Jinsi ya kupata Mussolini maisha kwa ajili ya misitu katika Active Directory kwa PowerShell?

Jinsi ya kupata maelezo ya msitu/miliki katika Active Directory kwa PowerShell?

Jinsi ya kupata njia ya “Zilizofutwa vitu” chombo katika Active Directory kwa PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Jinsi ya kuwawezesha AD Recycle Bin kipengele katika Active Directory kwa PowerShell?

Jinsi ya kurejesha Akaunti AD kutoka Recycle Bin katika Active Directory kwa PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Jinsi ya kupata majukumu FSMO na PowerShell?

Jinsi ya kuungana na mtawala domain maalum na PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Jinsi ya kupata sasa logon server na PowerShell?

Jinsi ya kufanya “gpupdate” kwenye kompyuta na PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Jinsi ya kuunda kundi jipya katika Active Directory kwa PowerShell?

Jinsi ya kuondoa kundi katika Active Directory kwa PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Jinsi ya kuongeza user kikundi katika Active Directory kwa PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Jinsi ya kuondoa user kutoka kundi katika Active Directory kwa PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Jinsi ya kupata makundi tupu (na hakuna wanachama) katika Active Directory kwa PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Jinsi ya kuhesabu makundi tupu (na hakuna wanachama) katika Active Directory kwa PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Jinsi ya kupata wanachama wa kundi katika Active Directory kwa PowerShell?

Jinsi ya kupata wanachama wa kundi na wanachama kujirudia katika Active Directory kwa PowerShell?

Jinsi ya kuhesabu idadi ya wanachama wa kundi na/bila wanachama kujirudia katika Active Directory kwa PowerShell?

Users

Jinsi ya kutumia wildcard katika chujio la “Kupata-ADUser” katika Active Directory kwa PowerShell?

Jinsi ya kuhamia mtumiaji mwingine ou katika Active Directory kwa PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Jinsi ya kupata Wanachama wote waliomo (Furushi) kwa mtumiaji na PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Jinsi ya kupata Wanachama (short jina/truncated) kwa mtumiaji na PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Jinsi ya kubadili jina Jina (majina kamili), (DISPLAYNAME), GivenName (FIRSTNAME), na ukoo (LastName) kwa ajili ya akaunti ya mtumiaji katika Active Directory kwa PowerShell?

Jinsi ya kubadili Maelezo, ofisi, na Namba ya simu kwa ajili ya akaunti ya mtumiaji katika Active Directory kwa PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Jinsi ya kuweka tarehe ya kumalizika muda na “31/12/2015” au “Kamwe” kwa ajili ya akaunti ya mtumiaji katika Active Directory kwa PowerShell?

Jinsi ya kufungua akaunti ya mtumiaji katika Active Directory kwa PowerShell?
Unlock-ADAccount $samAccountName

Jinsi ya kuwawezesha/afya ya akaunti user katika Active Directory kwa PowerShell?

Jinsi ya kuondoa akaunti user katika Active Directory kwa PowerShell?
Remove-ADUser $samAccountName

Jinsi ya upya nenosiri la akaunti user moja katika Active Directory kwa PowerShell?

Jinsi ya upya nenosiri kwa akaunti kadhaa user (wingi) katika Active Directory kwa PowerShell?

Jinsi ya kupata mmiliki wa faili katika Active Directory kwa PowerShell?

Jinsi ya kupata ou (Kitengo cha Utaratibu) kwa mtumiaji katika Active Directory kwa PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Jinsi ya kupata akaunti walemavu user katika Active Directory kwa PowerShell?

Jinsi ya kupata akaunti ya muda wake user katika Active Directory kwa PowerShell?
Search-ADAccount -AccountExpired

Jinsi ya kupata akaunti imefungwa user katika Active Directory kwa PowerShell?
Search-ADAccount -LockedOut

Jinsi ya kupata SID ya akaunti user katika Active Directory kwa PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Jinsi ya kubadilisha jina la mtumiaji kwa SID katika Active Directory kwa PowerShell?

Jinsi ya kubadilisha SID kwa jina la mtumiaji katika Active Directory kwa PowerShell?

Jinsi ya mgawanyiko Distinguished Jina la akaunti user katika Active Directory kwa PowerShell?

Jinsi ya kupata tarehe ya kuundwa/muundo wa akaunti user katika Active Directory kwa PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Jinsi ya kuonyesha hiari na lazima mali kwa ajili ya darasa “mtumiaji” katika Active Directory kwa PowerShell?

Jinsi ya kupata njia LDAP kwa mtumiaji katika Active Directory kwa PowerShell?

Jinsi ya kubadili CN (kisheria Jina) kwa mtumiaji katika Active Directory kwa PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

Jinsi ya kupata Kitengo cha Utaratibu (ou) mzazi wa mtumiaji katika Active Directory kwa PowerShell?

Jinsi ya kupata mmiliki wa mtumiaji (aliye Muumba akaunti) katika Active Directory kwa PowerShell?

Jinsi ya kubadilisha PwdLastSet sifa kwa mtumiaji katika Active Directory kwa PowerShell?

Computers

Jinsi ya mtihani channel salama kati ya kompyuta za mitaa na uwanja na PowerShell?
Test-ComputerSecureChannel

Jinsi ya kutengeneza channel salama kati ya kompyuta za mitaa na uwanja na PowerShell?
Test-ComputerSecureChannel -Repair

Jinsi ya kufunga akaunti kompyuta katika Active Directory kwa PowerShell?
Disable-ADAccount $computer

Jinsi ya kupata kompyuta na maalum mifumo ya uendeshaji katika Active Directory kwa PowerShell?

Organizational Unit (OU)

Jinsi ya kuunda Kitengo cha Utaratibu (ou) katika Active Directory kwa PowerShell?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

Jinsi ya kupata Kitengo cha Utaratibu (ou) maelezo katika Active Directory kwa PowerShell?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

Jinsi ya kubadili maelezo ya Kitengo cha Utaratibu (ou) katika Active Directory kwa PowerShell?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

Jinsi ya kuwawezesha/afya Kitengo cha Utaratibu (ou) kutoka ajali deletion katika Active Directory kwa PowerShell?

Jinsi ya kuwawezesha kufutwa ajali kwa wote Kitengo cha Utaratibu (ou) katika Active Directory kwa PowerShell?

Jinsi ya kufuta Kitengo cha Utaratibu (ou) kulindwa kutokana na ajali deletion katika Active Directory kwa PowerShell?

Jinsi ya kubadilisha Distinguished Jina la Kitengo cha Utaratibu (ou) kwa kisheria Jina katika Active Directory kwa PowerShell?

Jinsi ya kuorodhesha tupu Utaratibu Units (ous) na PowerShell?

Jinsi ya kupata meneja wa kundi na PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Jinsi ya kutafuta IP v4 (80.80.228.8) na Regex na 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

Jinsi ya kutafuta anwani MAC (C0-D9-62-39-61-2D) na Separator “-” pamoja Regex na 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

Jinsi ya kutafuta anwani MAC (C0: D9: 62: 39: 61: P2) na Separator “:” pamoja Regex na 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

Jinsi ya kutafuta tarehe (2015/10/02) na Regex na PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

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

Jinsi ya kutafuta barua pepe (user@domain.com) na Regex na 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

Jinsi ya kutafuta “guru” kutoka kamba mfano na Regex na PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Jinsi ya kutafuta “guru.com” kutoka kamba mfano na Regex na PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Jinsi ya kutafuta “powershell-guru.com” kutoka kamba mfano na Regex na PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Jinsi ya kutafuta “123” kutoka kamba mfano na Regex na PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Jinsi ya kutafuta “$” (dola ishara) kutoka kamba mfano na Regex na PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Jinsi ya kuchukua nafasi ya tabia (* Com) na mwingine (* .fr) katika kamba na Regex na PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Jinsi ya kuepuka kamba na Regex na PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Jinsi ya nguvu ukusanyaji wa kumbukumbu na takataka ushuru na PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Jinsi ya kupata RAM ukubwa wa kompyuta na PowerShell?

Up


Date

Jinsi ya kupata tarehe ya sasa na PowerShell?
Get-Date
[Datetime]::Now

Jinsi ya kuonyesha tarehe katika miundo mbalimbali na PowerShell?

Jinsi ya kubadilisha tarehe (DATETIME) hadi sasa (Kamba) na PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

Jinsi ya kubadilisha tarehe (Kamba) hadi sasa (DATETIME) na PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Jinsi ya mahesabu ya mabadiliko (idadi ya siku, masaa, dakika, au Seconds) kati ya tarehe mbili na 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

Jinsi ya kulinganisha tarehe mbili na 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

Jinsi ya kutatua safu ya tarehe kama “DATETIME” na PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Jinsi ya kuanza na kuacha stopwatch na PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Jinsi ya kupata siku ya sasa ya wiki na PowerShell?
(Get-Date).DayOfWeek #Sunday

Jinsi ya kupata tarehe jana na PowerShell?
(Get-Date).AddDays(-1)

Jinsi ya kupata idadi ya siku katika mwezi (mwezi Februari 2015) na PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Jinsi ya kujua mwaka mrefu na PowerShell?
[DateTime]::IsLeapYear(2015)

Jinsi ya kuorodhesha wakati kanda na PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Jinsi ya encode (na muundo ASCII) na Decode URL na PowerShell?

Ni EQUIVALENTS ya amri mtandao asili na PowerShell nini?

Jinsi ya kupata anwani ya IP na PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Jinsi ya afya IP v6 (IPv6) na PowerShell?

Jinsi ya kuhalalisha IP v4 (IPv4) na PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Jinsi ya kupata anwani ya IP ya nje na PowerShell?

Jinsi ya kupata jina la mpangishaji kutoka anwani ya IP na PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Jinsi ya kupata anwani ya IP kutoka hostname na PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Jinsi ya kupata FQDN kutoka hostname na PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Jinsi ya kupata mtandao Configuration (Ip, subnet, Gateway, na DNS) na PowerShell?

Jinsi ya kupata anwani MAC na PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Jinsi ya Ping kompyuta na PowerShell?

Jinsi ya kuangalia kama kompyuta ni kushikamana na mtandao na PowerShell?

Jinsi ya kufanya “whois” Luke ajili ya tovuti na PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Jinsi ya kupata maelezo ya IP ya umma (geolocation) na PowerShell?

Jinsi ya kuangalia kama bandari ni wazi/imefungwa na PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Jinsi ya kufanya “tracert” na PowerShell?
Test-NetConnection www.google.com -TraceRoute

Jinsi ya kurekebisha mtandao nyumbani uhusiano hadhi na PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Jinsi ya kuonyesha uhusiano bandari TCP na PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Jinsi ya kufupisha muda URL katika URL vidogo na PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Jinsi ya kupata mpangilio wa wakala na PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Jinsi ya kuangalia DNS cache juu ya ndani ya kompyuta na PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Jinsi ya wazi DNS cache juu ya ndani ya kompyuta na PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Jinsi ya wazi DNS cache kwenye kompyuta kijijini na PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Jinsi ya kusoma Majeshi faili na PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Jinsi ya kuzalisha password random na PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Jinsi ya kubadili password mitaa kwa ajili ya msimamizi kwenye kompyuta kijijini na PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Jinsi ya kupata password tarehe ya kumalizika muda wa akaunti katika Active Directory kwa PowerShell?

Up


Printers

Jinsi ya kuorodhesha Printers wote kwa server maalum na PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Jinsi ya kuorodhesha bandari zote kwa ajili ya server maalum na PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Jinsi ya kubadili maoni/eneo la mashine na PowerShell?

Jinsi ya asafishe (kufuta yote ya ajira) kwa printer na PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Jinsi ya magazeti ukurasa mtihani kwa ajili ya mashine na PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Jinsi ya kupata foleni magazeti kwa Printers na PowerShell?

Up


Regedit

Read

Jinsi ya kuorodhesha Usajili mizinga na PowerShell?
Get-ChildItem -Path Registry::

Jinsi ya kupata Usajili maadili na aina thamani na PowerShell?

Jinsi ya kuorodhesha Usajili subkeys muhimu na PowerShell?

Jinsi ya kuorodhesha subkeys Usajili muhimu katika njia ya kujirudia na PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Jinsi ya kupata subkeys na jina maalum na PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Jinsi ya kurudi tu jina la subkeys Usajili na PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Jinsi ya kuorodhesha maadili Usajili na PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Jinsi ya kusoma maalum Usajili thamani na PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Jinsi ya kusoma maalum Usajili thamani juu ya kijijini kompyuta na PowerShell?

Write

Jinsi ya kuunda mpya Usajili muhimu na PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Jinsi ya kuunda Usajili thamani na PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Jinsi ya kurekebisha zilizopo Usajili thamani na PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Jinsi ya kufuta Usajili thamani na PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Jinsi ya kufuta Usajili muhimu na PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Jinsi ya kujua kama Msajili muhimu lipo na PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Jinsi ya kujua kama thamani Usajili lipo na PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Jinsi ya kuondoa wahusika nyeupe-nafasi tangu mwanzo wa kamba na PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Jinsi ya kuondoa wahusika nyeupe-nafasi kutoka mwisho wa kamba na PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Jinsi ya kuondoa wahusika nyeupe-nafasi (mwanzo na mwisho) ya kamba na PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Jinsi ya kubadilisha kamba kwa kesi za juu kwa PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Jinsi ya kubadilisha kamba kupunguza kesi na PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Jinsi ya kuchagua substring “PowerShell” ya kamba “PowerShellGuru” na PowerShell?
$string.Substring(0,10)

Jinsi ya kuchagua substring “Guru” ya kamba “PowerShellGuru” na PowerShell?
$string.Substring(10)

Jinsi ya kuchagua idadi “123” wa “PowerShell123Guru” na PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Jinsi ya kupata sifuri-msingi ripoti ya “Guru” ya kamba “PowerShellGuru” na PowerShell?
$string.IndexOf('Guru') # 10

Jinsi ya kuangalia kama kamba ni null au tupu na PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Jinsi ya kuangalia kama kamba ni null, tupu, au lina tu ya wahusika nyeupe-nafasi na PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Jinsi ya kuangalia kama kamba ina barua maalum na PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Jinsi ya kurudi urefu wa kamba na PowerShell?
$string.Length

Jinsi ya concatenate masharti mawili na PowerShell?

Jinsi ya mechi kwa moja au mabano kadhaa “[]” katika kamba na PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Jinsi ya mechi kwa moja au mabano kadhaa “()” katika kamba na PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Jinsi ya mechi kwa moja au mabano kadhaa curly “{}” katika kamba na PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Jinsi ya mechi kwa moja au mabano kadhaa pembe “<>” katika kamba na PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Jinsi ya mechi barua yoyote lowercase (abc) katika kamba na PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Jinsi ya mechi upperletters yoyote (ABC) katika kamba na PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Jinsi ya mechi ya “[p” (uk chini kesi) katika kamba na PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Jinsi ya mechi “[P” (P ghorofani kesi) katika kamba na PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Jinsi ya kuchukua nafasi ya mstari na mstari mwingine na PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Jinsi ya kubadilisha mgawanyo operesheni ya kamba (asilimia) na PowerShell?
(1/2).ToString('P')

Jinsi ya kutatua masharti zenye namba na PowerShell?

Jinsi ya kuchagua neno la mwisho la hukumu na PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

Jinsi ya kupata neno kubwa ya kifungo na PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

Jinsi ya kuhesabu idadi ya mara kamba yupo ndani ya hukumu na PowerShell?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

Jinsi ya kunakili kila tabia katika kamba kwa tabia safu na PowerShell?

Jinsi ya kubadilisha barua ya kwanza kwa uppercase ya kamba na PowerShell?

Jinsi ya pedi (kushoto au kulia) kamba na PowerShell?

Jinsi ya encode na Decode kamba kwa Base64 na PowerShell?

Jinsi ya kubadilisha idadi (kwenda na kutoka) binary na PowerShell?

Jinsi ya kurudi tu iliyopita mzazi kabrasha katika njia na PowerShell?

Jinsi ya kurudi tu item ya mwisho katika njia na PowerShell?

Up


Math

Jinsi ya kuorodhesha mbinu za System.Math darasa na PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Jinsi ya kurudi thamani kamili na PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Jinsi ya kurudi pembe ambaye sine ni idadi iliyotajwa na PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Jinsi ya kurudi thamani dari na PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Jinsi ya kurudi sakafu thamani na PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Jinsi ya kurudi asili (msingi e) logi ya idadi iliyotajwa na PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

Jinsi ya kurudi msingi 10 logi ya idadi iliyotajwa na PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

Jinsi ya kurudi upeo wa maadili wawili pamoja PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Jinsi ya kurudi chini ya maadili wawili pamoja PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Jinsi ya kurudi idadi kukulia madarakani fulani na PowerShell?
[Math]::Pow(2,4) #Returns 16

Jinsi ya kurudi thamani alisema kwa karibu zaidi muhimu thamani na PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Jinsi ya kurudi sehemu muhimu ya iliyotajwa alisema idadi na PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Jinsi ya kurudi mizizi ya mraba ya idadi iliyotajwa na PowerShell?
[Math]::Sqrt(16) #Returns 4

Jinsi ya kurudi PI mara kwa mara na PowerShell?
[Math]::Pi #Returns 3,14159265358979

Jinsi ya kurudi asili logarithmic msingi (mara kwa mara e) na PowerShell?
[Math]::E #Returns 2,71828182845905

Jinsi ya kuangalia kama idadi ni hata au isiyo ya kawaida na PowerShell?
[bool]($number%2)

Up


Hashtables

Jinsi ya kuunda hashtable tupu kwa PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Jinsi ya kuunda hashtable na vitu na PowerShell?

Jinsi ya kuunda hashtable yamepangwa kwa ufunguo/jina (kuamuru kamusi) na vitu na PowerShell?

Jinsi ya kuongeza vitu (jozi ufunguo-thamani) kwa hashtable na PowerShell?
$hashtable.Add('Key3', 'Value3')

Jinsi ya kupata thamani maalum ya hashtable na PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Jinsi ya kupata thamani ya kiwango cha chini cha hashtable na PowerShell?

Jinsi ya kupata thamani ya upeo wa hashtable na PowerShell?

Jinsi ya kurekebisha vitu katika hashtable na PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Jinsi ya kuondoa vitu katika hashtable na PowerShell?
$hashtable.Remove('Key1')

Jinsi ya wazi hashtable na PowerShell?
$hashtable.Clear()

Jinsi ya kuangalia uwepo wa maalum ufunguo/thamani katika hashtable na PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Jinsi ya kutatua na ufunguo/thamani katika hashtable na PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Jinsi ya kuunda safu tupu kwa PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Jinsi ya kuunda safu na vitu na PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Jinsi ya kuongeza vitu kwa safu na PowerShell?
$array += 'D'
[void]$array.Add('D')

Jinsi ya kurekebisha bidhaa katika safu na PowerShell?
$array[0] = 'Z' # 1st item[0]

Jinsi ya kuangalia ukubwa wa safu na PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Jinsi ya kupata bidhaa moja/kadhaa/vitu vyote katika safu na PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Jinsi ya kuondoa vitu tupu katika safu na PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Jinsi ya kuangalia kama bidhaa ipo katika safu na PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Jinsi ya kupata ripoti ya idadi ya bidhaa katika safu na PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Jinsi ya kubadili utaratibu wa vitu katika safu na PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Jinsi ya kuzalisha bidhaa random kutoka safu na PowerShell?
$array | Get-Random

Jinsi ya kutatua safu katika wakipanda/akishuka njia na PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Jinsi ya kuhesabu idadi ya vitu katika safu na PowerShell?
$array.Count

Jinsi ya kuongeza safu hadi nyingine na PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Jinsi ya kupata marudio kutoka safu na PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Jinsi ya kuondoa marudio kutoka safu na PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Jinsi ya kuunda safu na vitu kuanzia na kiambishi awali (“user01”, “user02”, … “user10”) na PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Jinsi ya kuorodhesha ACL ya AD mtumiaji na PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Jinsi ya kuorodhesha ACL ya kabrasha na PowerShell?
(Get-Acl -Path C:\scripts).Access

Jinsi ya kuorodhesha maalum entries ACL ruhusa (watumiaji au vikundi) ya AD mtumiaji na PowerShell?

Up


Variables

Ni aina ya kawaida data na PowerShell nini?

Jinsi ya kupata kiwango cha chini na maadili ya kiwango cha juu kwa ajili ya baadhi ya vigezo ya aina na PowerShell?

Jinsi ya mtihani datatype na PowerShell?

Jinsi ya kuunda Hapa-Kamba kutofautiana na PowerShell?

Jinsi ya kuunda kutofautiana na PowerShell?
$powershellGuru = 'Hello'

Jinsi ya kuunda kutofautiana mara kwa mara na PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Jinsi ya kuunda variable kimataifa na PowerShell?
$Global:powershellGuru = 'Hello'

Jinsi ya kusoma kutofautiana na PowerShell?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

Jinsi ya kuangalia aina ya kutofautiana na PowerShell?
$powershellGuru.GetType()

Jinsi ya kupata vigezo katika upeo wa kimataifa na PowerShell?
Get-Variable -Scope Global

Jinsi ya kupata vigezo maalum kwa jina na PowerShell?
Get-Variable -Include *Preference -Exclude W*

Jinsi ya hawawajui data maalum ya aina ya kutofautiana na PowerShell?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

Jinsi ya initialize vigezo mbalimbali kwa thamani sawa na PowerShell?
$a = $b = $c = $d = $e = 0

Ni kwa ajili ya kutofautiana vinginevyo, “$ _” na PowerShell nini?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

Jinsi ya kuondoa vigezo kwa jina zinazoanza “kuhesabu” na PowerShell?
Remove-Variable -Name count*

Jinsi ya kupata vigezo mitaa mazingira na PowerShell?
Get-ChildItem -Path Env:

Jinsi ya kupata Njia Mazingira Variable mstari kwa mstari na PowerShell?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

Jinsi ya kuongeza mpya njia (zamani C:. \ SysinternalsSuite) kwa njia Mazingira Variable na PowerShell?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

Jinsi ya concatenate vigezo na PowerShell?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

Jinsi ya kutumia ErrorVariable na PowerShell?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

Jinsi ya kuwawezesha/afya sawa na “chaguo Wazi” (VBScript: inahitaji kwamba kutofautiana kutangazwa) na PowerShell?

Up


Static .NET Methods

Jinsi ya kupata wanachama tuli na PowerShell?
[DateTime] | Get-Member -Static

Up


Sounds

Jinsi ya kucheza “beep” sauti na PowerShell?
[System.Console]::Beep()

Jinsi ya kucheza “asteriski” sauti na PowerShell?
[System.Media.SystemSounds]::Asterisk.Play()

Jinsi ya kucheza “Moderators” sauti na PowerShell?
[System.Media.SystemSounds]::Exclamation.Play()

Jinsi ya kupata sauti inapatikana kwa PowerShell?
[System.Media.SystemSounds] | Get-Member -Static

Jinsi ya kucheza “wav” sauti na PowerShell?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
au
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

Jinsi ya kuamsha hotuba ya maandishi asilia na PowerShell?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

Jinsi ya kusoma faili za XML na PowerShell?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

Jinsi ya kuuza nje data kama faili XML na PowerShell?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

Jinsi ya kuagiza data kutoka CLIXML faili na PowerShell?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

Jinsi ya kuunda GUI msingi (Windows kidato) na PowerShell?

Up


Characters

Jinsi ya kubadilisha thamani ASCII kwa tabia na PowerShell?
[char]64

Jinsi ya kubadilisha tabia kwa thamani ASCII na PowerShell?
[int][char]'@'

Jinsi ya kuzalisha alfabeti ya Kiingereza na PowerShell?
[char[]](97..122)

Up


Compare

Jinsi ya kulinganisha arrays mbili na PowerShell?

Jinsi ya kulinganisha michakato miwili na PowerShell?

Up


Microsoft Exchange

Jinsi ya kuzipata orodha ya vifaa vya mkononi ikatokezea mailbox watumiaji ‘na PowerShell?
Get-ActiveSyncDeviceStatistics

Jinsi ya kuongeza “Full Kupata” ruhusa ya mailbox kwa mtumiaji na PowerShell?
Add-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess'

Jinsi ya kuondoa “Full Kupata” ruhusa ya mailbox kwa mtumiaji na PowerShell?
Remove-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess' -InheritanceType 'All'

Jinsi ya kuongeza “Tuma Kama” ruhusa ya mailbox kwa mtumiaji na PowerShell?
Add-ADPermission -Identity $dn -User 'DOMAIN\powershellguru' -ExtendedRights 'Send-As'

Jinsi ya kuondoa “Tuma Kama” ruhusa ya mailbox kwa mtumiaji na PowerShell?

Jinsi ya kupata Inbox sheria kutoka mailbox kwa PowerShell?
Get-InboxRule -Mailbox 'Powershell.Guru'

Jinsi ya kupata SMTP anwani ajili ya watumiaji ambao wana OWA (Outlook Mtandao Access) kuwezeshwa na PowerShell?
Get-CASMailbox -Filter{OWAEnabled -eq $true} | Select-Object -Property Name, PrimarySMTPAddress

Exchange 2007

Jinsi ya kufunga kabla ya requisites kwa ajili ya server Exchange Server 2007 Hub Usafiri, Mailbox (MBX), na Mteja Kupata Server (CAS) na PowerShell?

Exchange 2010

Jinsi ya kufunga kabla ya requisites kwa ajili ya server Exchange Server 2010 Hub Usafiri, Mailbox (MBX), na Mteja Kupata Server (CAS) na PowerShell?

Exchange 2013

Jinsi ya kufunga kabla ya requisites kwa ajili ya server Exchange Server 2013 Mailbox (MBX) na Mteja Kupata Server (CAS) na PowerShell?