FAQ POWERSHELL BIL-MALTI

By | May 17, 2015


beta-v2-0


Kunċett : L-aktar mistoqsijiet frekwenti dwar Powershell.

Tista ‘tuża din il-lista b’modi differenti :

  • Li kopja / paste jikkmanda fis iskrittura
  • Biex tara malajr l-sintassi ta ‘kmand speċifiku
  • Biex itejbu l-għarfien tekniku tiegħek
  • Biex jiskopru ordnijiet ġodda
  • Biex tipprepara intervista tax-xogħol

Aġġornata
2 Lulju, 2015
AwturSteve Renard
Sorsmaltese.powershell-guru.com
Kategoriji
75
Mistoqsijiet
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

Kif ikun determinat verżjoni tiegħi ta ‘PowerShell?

Kif jitmexxa PowerShell fil-verżjoni ieħor għal kompatibilità b’lura?
powershell.exe -Version 2.0

Kif jeħtieġu verżjoni PowerShell minimu (3.0 u ogħla) fi b’kitba ma PowerShell?
#Requires -Version 3.0

Kif jeħtieġu privileġġi amministrattivi għal b’kitba bl PowerShell?

Kif jikkontrollaw il-parametri ta ‘iskrittura ma PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Kif tikseb l-informazzjoni għall-utent attwali ma PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Kif toħloq, teditja, u rikarigu profil ma ‘PowerShell?

Kif jagħmlu waqfa ta ‘5 sekondi / minuta b’kitba ma PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Kif tikseb l-aħħar darba boot mal PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Kif tikseb aċċeleraturi tip ma PowerShell?

Kif jiġu elenkati l-programmi l-istartjar bil PowerShell?

Kif uninstall applikazzjoni ma PowerShell?

Kif għandek tieħu screenshot ta ‘l-desktop kollu jew ta’ tieqa attiva ma PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Kif tikseb l-għadd messaġġ għall-kjuwijiet MSMQ ma PowerShell?

Kif jiġu stabbiliti l-politika ta ‘eżekuzzjoni ma PowerShell?

Kif tinħoloq shortcut ma PowerShell?

Kif biex jagħrfu jew unpin programm għall-taskbar ma PowerShell?

Kif tiftaħ Windows Explorer mal PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Kif telenka sewwieqa apparat ma PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Kif tinħoloq GUID ma PowerShell?

Kif tikseb l-post tad-direttorju temporanju għall-utent attwali ma PowerShell?
[System.IO.Path]::GetTempPath()

Kif tissieħeb triq u triq f’wieħed passaġġ wieħed minuri ma PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Kif għall-lista cmdlets kollha “Get- *” ma PowerShell?
Get-Command -Verb Get

Kif telenka folders sistema speċjali ma PowerShell?

Kif impunjazzjoni ISO fajls / VHD ma PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Kif biex jiċċekkjaw verżjonijiet Qafas NET installati mal PowerShell?

Kif biex jiċċekkjaw jekk il-verżjoni Qafas NET 4.5 huwa installat ma ‘PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Kif tibda u tieqaf traskrizzjoni (li jinħoloq rekord tas-sessjoni Windows PowerShell) ma PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Kif tibdel l-direttorju kurrenti għal lokazzjoni speċifika ma PowerShell?
Set-Location -Path 'C:\scripts'

Kif ċar l-iskrin bl PowerShell?
Clear-Host
cls # Alias

Kif tibdel l-riżoluzzjoni tal-wirja bl PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Kif jiġu stabbiliti l-“full screen” tieqa bil PowerShell?
mode.com 300

Kif tikseb dimensjonijiet (wisa ‘u għoli) ta’ stampa mal PowerShell?

Kif tikseb l-prodott ewlieni Windows PowerShell ma?

Perfmon

Kif tikseb l-kurrent “Time% Processor” (medja) fl-aħħar 5 sekondi (10 darbiet) ma PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Kif tagħbija assemblaġġi PowerShell?

Kif biex jiċċekkjaw assemblaġġi NET attwali mgħobbija bil PowerShell?

Kif issib l-GAC (Assemblea Global Cache) passaġġ bl PowerShell?

Clipboard

Kif kopja riżultati lill-clipboard ma PowerShell?

Kif tikseb l-kontenut tal-clipboard ma PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Kif tikseb l-hotfixes installati mal PowerShell?
Get-HotFix -ComputerName $computer

Kif tikseb l-hotfixes installati qabel / wara data speċifika ma 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

Kif biex jiċċekkjaw jekk hotfix huwa installat ma ‘PowerShell?
Get-HotFix -Id KB2965142

Kif tikseb l-hotfixes installat fuq kompjuter remot bl PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Kif tikseb informazzjoni pagefile ma PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Kif tikseb l-daqs rakkomandat (MB) għall-pagefile ma PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Kif tinħoloq pagefile (4096 MB) dwar il- (D 🙂 issuq bil PowerShell?

Kif tħassar pagefile dwar il- (C 🙂 drive ma PowerShell?

Maintenance

Kif biex jiċċekkja l-frammentazzjoni ta ‘drive ma PowerShell?

Kif biex jiċċekkja l-ispazju disk drives ta ‘mal PowerShell?

Up


Files

Kif tiftaħ fajl ma PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Kif jaqraw fajl ma PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Kif jiktbu output għall-fajl ma PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Kif tikseb l-fullname tal-fajl iskrittura attwali PowerShell?
$MyInvocation.MyCommand.Path

Kif jikkompressa / fajls zip mal PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

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

Kif tara l-fajls fil arkivju code bil PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Kif juru d-daqs ta ‘fajl fi KB mal PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Kif issib fajls akbar jew inqas minn 1 GB ma PowerShell?

Kif turi l-isem ta ‘fajl mingħajr estensjoni ma PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Kif juru l-estensjoni ta ‘fajl ma PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Kif tikseb l-verżjoni fajl ta ‘fajl ma PowerShell?

Kif tikseb l-hash tal-fajl ma PowerShell?
(Get-FileHash $file).Hash

Kif tikseb l-checksum MD5 / SHA1 ta ‘fajl ma PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Kif juru fajls moħbija ma PowerShell?

Kif biex jiċċekkjaw jekk fajl għandu estensjoni PowerShell?

Kif jiffissaw fajl bħala “Aqra biss” ma PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Kif il-bidla l-“LastWriteTime” attribut li għaddiet ġimgħa għal fajl ma PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Kif tinħoloq fajl ġdid ma PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Kif li tibdel isem fajl ma PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Kif tibdel isem ingrossa / tal-lott fajls multipli ma ‘PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Kif tħassar fajl ma PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Kif juru l-aħħar 10 linji ta ‘fajl ma PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Kif tiżblokka diversi fajls ta ‘folder mal PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Kif tneħħi linji vojta minn fajl bl PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Kif biex jiċċekkjaw jekk teżisti fajl ma PowerShell?

Kif tikseb l-aktar ġodda / eqdem fajl maħluqa fil-folder mal PowerShell?

Kif tneħħi linji duplikat minn fajl bl PowerShell?

Kif tikseb fajls maħluqin aktar jew inqas minn 1 xahar fil-folder mal PowerShell?

Kif tikseb fajls maħluqin aktar jew inqas minn 1 sena fil-folder mal PowerShell?

Kif tesporta l-valur ta ‘varjabbli għall-fajl ma PowerShell?
Set-Content -Path file.txt -Value $variable

Kif jgħodd in-numru ta ‘fajls (* txt) fil-folder mal PowerShell?

Kif tfittex string ġewwa fajls multipli PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

Kif juru l-ewwel / l-aħħar linja ta ‘fajl ma PowerShell?

Kif juru numru linja speċifika ta ‘fajl ma PowerShell?

Kif jgħodd in-numru ta ‘linji ta’ fajl ma PowerShell?

Kif jgħodd in-numru ta ‘karattri u kliem ta’ fajl ma PowerShell?

Kif tniżżel fajl ma PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Kif juru l-traġitt sħiħ ta ‘fajl ma PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Kif kopja fajl wieħed għal folder mal PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Kif kopja fajl wieħed għall folders multipli ma PowerShell?

Kif kopja fajls multipli biex folder wieħed ma 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

Kif issib Globali Catalog servers Active Directory ma PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Kif issib siti fl-Active Directory ma PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Kif issib l-kontrollur ta ‘domain attwali PowerShell?
(Get-ADDomainController).HostName

Kif issib l-kontrolluri ta ‘domain fi dominju ma PowerShell?

Kif issib l-fallimenti replikazzjoni AD ma PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Kif issib l-ħajja tombstone għall-foresti fil-Active Directory ma PowerShell?

Kif tikseb id-dettalji tal-foresta / dominju Active Directory ma PowerShell?

Kif tikseb l-passaġġ ta ‘l- “Oġġetti Imħassar” kontenitur fil-Active Directory ma PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Kif tippermetti l-AD karatteristika Recycle Bin fl-Active Directory ma PowerShell?

Kif biex jirrestawraw Kont AD mill-Recycle Bin fl-Active Directory ma PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Kif issib l-irwoli FSMO ma PowerShell?

Kif biex jgħaqqdu ma ‘kontrollur ta’ domain speċifiku ma PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Kif tikseb l-server logon attwali PowerShell?

Kif iwettqu “gpupdate” fuq il-kompjuter ma ‘PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Kif tinħoloq grupp ġdid fil-Active Directory ma PowerShell?

Kif tneħħi grupp Active Directory ma PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Kif żid utent għal grupp fil-Active Directory ma PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Kif tneħħi utent minn grupp Active Directory ma PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Kif issib gruppi vojta (bl-ebda membru) fil-Active Directory ma PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Kif jgħodd gruppi vojta (bl-ebda membru) fil-Active Directory ma PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Kif tikseb l-membri ta ‘grupp fi Active Directory ma PowerShell?

Kif tikseb l-membri ta ‘grupp ma’ membri rikursivi fil Active Directory ma PowerShell?

Kif jgħodd in-numru ta ‘membri ta’ grupp bi / mingħajr membri rikursivi fil Active Directory ma PowerShell?

Users

Kif għandek tuża Wildcard fil-filtru ta ‘”Get-ADUser” Active Directory ma PowerShell?

Kif jimxu utent biex OU ieħor Active Directory ma PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Kif issib l-Membri kollha li huma (nested) għal utent ma PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Kif tikseb l-Membri (isem qasir / maqtugħ) għal utent ma PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Kif tibdel isem l-Isem (fullname), (DisplayName), GivenName (FirstName), u Kunjom (LastName) għal kont utent Active Directory ma PowerShell?

Kif il-bidla l-Deskrizzjoni, Uffiċċju, u n-numru tat-telefown għal kont utent Active Directory ma PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Kif jiġu stabbiliti l-data ta ‘skadenza għal “31/12/2015” jew “Qatt” għal kont utent Active Directory ma PowerShell?

Kif nisfruttaw kont ta ‘utent fil-Active Directory ma PowerShell?
Unlock-ADAccount $samAccountName

Kif tippermetti / jiskonnettja kont ta ‘utent fil-Active Directory ma PowerShell?

Kif tneħħi kont ta ‘utent fil-Active Directory ma PowerShell?
Remove-ADUser $samAccountName

Kif reset password għall-kont utent wieħed fil-Active Directory ma PowerShell?

Kif reset password għal diversi kontijiet utent (bulk) fil Active Directory ma PowerShell?

Kif issib l-proprjetarju ta ‘fajl fi Active Directory ma PowerShell?

Kif issib l-OU (unità organizzattiva) għal utent fil-Active Directory ma PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Kif issib kontijiet utent b’diżabilità fl-Active Directory ma PowerShell?

Kif issib kontijiet utent skadew fil Active Directory ma PowerShell?
Search-ADAccount -AccountExpired

Kif issib kontijiet utent maqful fil Active Directory ma PowerShell?
Search-ADAccount -LockedOut

Kif issib l-SID ta ‘kont ta’ utent fil-Active Directory ma PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Kif jistgħu jikkonvertu username biex SID fl-Active Directory ma PowerShell?

Kif jistgħu jikkonvertu l-SID li username fi Active Directory ma PowerShell?

Kif li jaqsam l-Isem Distinti ta ‘kont ta’ utent fil-Active Directory ma PowerShell?

Kif issib id-data tal-ħolqien / modifika ta ‘kont ta’ utent fil-Active Directory ma PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Kif juru l-proprjetajiet fakultattivi u obbligatorji għall-klassi “User” Active Directory ma PowerShell?

Kif tikseb l-passaġġ LDAP għal utent fil-Active Directory ma PowerShell?

Kif tibdel l-NM (Canonical Isem) għal utent fil-Active Directory ma PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

Kif tikseb l-unità organizzattiva (OU) ġenitur ta ‘utent fil-Active Directory ma PowerShell?

Kif tikseb l-proprjetarju ta ‘utent (li ħoloq il-kont) fil-Active Directory ma PowerShell?

Kif jistgħu jikkonvertu l-attribut PwdLastSet għal utent fil-Active Directory ma PowerShell?

Computers

Kif biex jittestjaw il-kanal sigur bejn il-kompjuter lokali u l-dominju ma PowerShell?
Test-ComputerSecureChannel

Kif it-tiswija l-kanal sigur bejn il-kompjuter lokali u l-dominju ma PowerShell?
Test-ComputerSecureChannel -Repair

Kif li jiskonnettja kont kompjuter fl-Active Directory ma PowerShell?
Disable-ADAccount $computer

Kif issib kompjuters Operating Systems speċifiċi fil-Active Directory ma PowerShell?

Organizational Unit (OU)

Kif jista ‘jinħoloq unità organizzattiva (OU) fil-Active Directory ma PowerShell?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

Kif tikseb unità organizzattiva (OU) dettalji fil Active Directory ma PowerShell?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

Kif tibdel id-deskrizzjoni ta ‘unità organizzattiva (OU) fil-Active Directory ma PowerShell?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

Kif tippermetti / jiskonnettja unità organizzattiva (OU) minn tħassir aċċidentali fil-Active Directory ma PowerShell?

Kif tippermetti t-tħassir aċċidentali kollha għall-unità organizzattiva (OU) fil-Active Directory ma PowerShell?

Kif ħassar unità organizzattiva (OU) protetti minn tħassir aċċidentali fil-Active Directory ma PowerShell?

Kif jistgħu jikkonvertu Isem ta Distint ta ‘unità organizzattiva (OU) sa Canonical Isem Active Directory ma PowerShell?

Kif telenka unitajiet organizzattivi vojta (ous) ma PowerShell?

Kif tikseb l-manager ta ‘grupp ma PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Kif estratt ta ‘v4 indirizz IP (80.80.228.8) ma regex ma 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

Kif estratt l-indirizz MAC (C0-D9-62-39-61-2D) ma separatur “-” ma regex ma 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

Kif estratt l-indirizz MAC (C0: D9: 62: 39: 61: 2D) ma separatur “:” bl regex ma 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

Kif estratt data (2015/10/02) ma regex ma PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Kif estratt URL (www.powershell-guru.com) ma regex ma PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Kif estratt email (user@domain.com) ma regex ma 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

Kif estratt “guru” mill-eżempju string ma regex ma PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Kif estratt “guru.com” mill-eżempju string ma regex ma PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Kif estratt “powershell-guru.com” mill-eżempju string ma regex ma PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Kif estratt “123” mill-eżempju string ma regex ma PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Kif estratt “$” (sinjal dollaru) mill-eżempju string ma regex ma PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Kif biex jissostitwixxu karattru (* Com) ma ‘ieħor (* .fr) fi string ma regex ma PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Kif jaħarbu string ma regex ma PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Kif seħħ ġabra ta ‘memorja mill-kollettur żibel mal PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Kif tikseb l-daqs RAM ta ‘kompjuter ma PowerShell?

Up


Date

Kif tikseb id-data attwali PowerShell?
Get-Date
[Datetime]::Now

Kif juru d-data fil-formati differenti ma PowerShell?

Kif jistgħu jikkonvertu data (DateTime) sa data (String) ma PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

Kif jistgħu jikkonvertu data (String) sa data (DateTime) ma PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Kif tikkalkula d-differenza (numru ta ‘jiem, sigħat, minuti, jew Seconds) bejn żewġ dati ma 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

Kif tqabbel żewġ dati ma 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

Kif biex issolvi firxa ta ‘dati bħal “dateTime” ma PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Kif tibda u tieqaf stopwatch ma PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Kif tikseb l-jum kurrenti tal-ġimgħa ma ‘PowerShell?
(Get-Date).DayOfWeek #Sunday

Kif tikseb data bieraħ ma PowerShell?
(Get-Date).AddDays(-1)

Kif tikseb l-għadd ta ‘ġranet fix-xahar (fi Frar 2015) ma PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Kif wieħed ikun jaf sena biżestili ma PowerShell?
[DateTime]::IsLeapYear(2015)

Kif telenka żoni tal-ħin ma PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Kif jikkodifikaw (sa format ASCII) u jiddekowdja URL mal PowerShell?

Liema huma l-ekwivalenti ta ‘kmandi tan-netwerk nattivi mal PowerShell?

Kif tikseb indirizzi IP mal PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Kif jiskonnettja indirizz IP v6 (IPv6) ma PowerShell?

Kif biex jivvalida l-indirizz IP v4 (IPv4) ma PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Kif issib l-indirizz IP estern ma PowerShell?

Kif issib l-hostname minn indirizz IP ma PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Kif issib l-indirizz IP minn hostname ma PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Kif issib l-FQDN minn hostname ma PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Kif issib l-konfigurazzjoni tan-network (Ip, Subnet, Gateway, u DNS) ma PowerShell?

Kif issib l-indirizz MAC ma PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Kif ping kompjuter bil PowerShell?

Kif biex jiċċekkjaw jekk il-kompjuter huwa konness mal-internet bil PowerShell?

Kif biex iwettqu “whois” lookup għal websajt ma PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Kif tikseb dettalji ta ‘IP pubbliku (Lokalità ġeografika) ma PowerShell?

Kif biex jiċċekkjaw jekk port hija miftuħa / magħluqa PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Kif iwettqu “Tracert” ma PowerShell?
Test-NetConnection www.google.com -TraceRoute

Kif jiffissaw profil konnessjoni tan-netwerk dar mal PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Kif juru l-konnessjonijiet tal-port TCP ma PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Kif biex jitqassar URL twil fi URL ċkejkna ma PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Kif tikseb settings prokura mal PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Kif biex jiċċekkja l-cache DNS fuq kompjuter lokali ma PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Kif ċar cache DNS fuq kompjuter lokali ma PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Kif ċar cache DNS fuq il-kompjuters remoti bl PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Kif taqra l-Hosts fajl ma PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Kif biex jiġġeneraw password każwali mal PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Kif tibdel l-password lokali għal amministratur fuq server remot bl PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Kif issib l-data ta ‘skadenza password ta’ kont fil-Active Directory ma PowerShell?

Up


Printers

Kif telenka l-printers għal server speċifiku ma PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Kif jiġu elenkati l-portijiet kollha għal server speċifiku ma PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Kif tibdel l-kumment / post ta ‘printer ma PowerShell?

Kif li jnaddaf (tikkanċella impjiegi kollha) għal printer ma PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Kif jistampaw paġna tat-test għal printer ma PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Kif tikseb kjuwijiet print għall-printers bil PowerShell?

Up


Regedit

Read

Kif telenka ġarer reġistru ma PowerShell?
Get-ChildItem -Path Registry::

Kif tikseb valuri tar-reġistru u tipi valur ma PowerShell?

Kif telenka subkeys ewlenin tar-reġistru ma PowerShell?

Kif telenka subkeys reġistru ewlenin b’mod rikursivi ma PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Kif issib subkeys ma ‘isem speċifiku PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Kif jirritornaw biss l-isem ta ‘l-subkeys reġistru ma PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Kif lista reġistru valuri ma PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Kif taqra valur reġistru speċifiku ma PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Kif taqra valur reġistru speċifiku fuq kompjuter remot bl PowerShell?

Write

Kif tinħoloq reġistru ewlieni ġdid ma PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Kif tinħoloq valur reġistru ma PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Kif timmodifika valur tar-reġistru eżistenti ma PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Kif ħassar valur reġistru ma PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Kif ħassar ewlenin reġistru ma PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Kif test jekk teżisti reġistru ċentrali ma PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Kif test jekk jeżisti valur reġistru ma PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Kif tneħħi karattri abjad fl-ispazju mill-bidu ta ‘string mal PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Kif tneħħi karattri abjad fl-ispazju mill-aħħar ta ‘string mal PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Kif tneħħi karattri abjad-ispazju (li jibda u jispiċċa) ta ‘string mal PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Kif jistgħu jikkonvertu string għall-każ ta ‘fuq ma PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Kif jistgħu jikkonvertu string biex ibaxxu każ ma PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Kif tagħżel l-substring “PowerShell” tas-sekwenza “PowerShellGuru” ma PowerShell?
$string.Substring(0,10)

Kif tagħżel l-substring “Guru” tas-sekwenza “PowerShellGuru” ma PowerShell?
$string.Substring(10)

Kif tagħżel in-numru “123” ta ‘”PowerShell123Guru” ma PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Kif tikseb l-indiċi b’bażi ​​żero ta ‘”Guru” tas-sekwenza “PowerShellGuru” ma PowerShell?
$string.IndexOf('Guru') # 10

Kif biex jiċċekkjaw jekk string huwa null jew vojta ma PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Kif biex jiċċekkjaw jekk string huwa null, vojta, jew tikkonsisti biss ta ‘karattri abjad ispazju ma’ PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Kif biex jiċċekkjaw jekk string fiha ittra speċifiku ma PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Kif jirritornaw it-tul ta ‘string mal PowerShell?
$string.Length

Kif concatenate żewġ kordi mal PowerShell?

Kif biex jaqblu għal diversi parentesi waħda jew “[]” fi string mal PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Kif biex jaqblu għal diversi parentesi waħda jew “()” fi string mal PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Kif biex jaqblu għal diversi parentesi kaboċċi waħda jew “{}” fi string mal PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Kif biex jaqblu għal diversi parentesi angolu wieħed jew “<>” fi string mal PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Kif biex jaqblu xi ittri lowercase (ABC) fi string ma PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Kif biex jaqblu xi upperletters (ABC) fi string ma PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Kif jaqblu “[p” (p żgħira) fi string mal PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Kif jaqblu “[P” (b’ittri kbar P) fi string mal PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Kif biex jissostitwixxu linja mal-linja ieħor ma PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Kif jistgħu jikkonvertu operazzjoni diviżjoni għal string (persentaġġ) ma PowerShell?
(1/2).ToString('P')

Kif biex issolvi kordi li jkun fihom numri ma PowerShell?

Kif tagħżel l-aħħar kelma ta ‘sentenza ma PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

Kif tikseb l-akbar kelma ta ‘sentenza ma PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

Kif jgħodd in-numru ta ‘drabi string ikun preżenti fiż sentenza ta ma PowerShell?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

Kif kopja kull karattru string għal firxa karattru ma PowerShell?

Kif jistgħu jikkonvertu l-ewwel ittra lill uppercase ta ‘string mal PowerShell?

Kif pad (lemin jew xellug) string ma PowerShell?

Kif jikkodifikaw u jiddekowdja string li Base64 ma PowerShell?

Kif jistgħu jikkonvertu numru (sa u minn) binarja ma ‘PowerShell?

Kif jirritornaw biss l-aħħar folder parent fi triq ma PowerShell?

Kif jirritornaw biss l-aħħar oġġett triq ma PowerShell?

Up


Math

Kif jiġu elenkati l-metodi tal-klassi System.Math ma PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Kif biex jirritorna l-valur assolut bil PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Kif jirritornaw l-angolu li sine huwa n-numru speċifikat ma PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Kif jirritornaw il-valur limitu ma PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Kif jirritornaw il-valur art ma PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Kif jirritornaw il-naturali (bażi e) logaritmu ta ‘numru speċifikat ma PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

Kif jirritornaw il-bażi ta ’10 logaritmu ta’ numru speċifiku ma PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

Kif biex jirritorna l-massimu ta ‘żewġ valuri ma PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Kif biex jirritorna l-minimu ta ‘żewġ valuri ma PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Kif jirritornaw numru jiżdied għal setgħa speċifikata bi PowerShell?
[Math]::Pow(2,4) #Returns 16

Kif jirritornaw valur deċimali sa l-eqreb valur integrali mal PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Kif biex jirritorna l-parti integrali ta ‘numru deċimali speċifikat ma PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Kif biex jirritorna l-għerq kwadrat ta ‘numru speċifiku ma PowerShell?
[Math]::Sqrt(16) #Returns 4

Kif jirritornaw il-kostanti PI ma PowerShell?
[Math]::Pi #Returns 3,14159265358979

Kif jirritornaw il-bażi logaritmika naturali (kostanti e) ma PowerShell?
[Math]::E #Returns 2,71828182845905

Kif biex jiċċekkjaw jekk numru huwa saħansitra jew fard ma PowerShell?
[bool]($number%2)

Up


Hashtables

Kif jista ‘jinħoloq hashtable vojta ma PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Kif tinħoloq hashtable ma ‘oġġetti bil PowerShell?

Kif tinħoloq hashtable magħżula mill ċavetta / isem (dizzjunarju ordnati) ma ‘oġġetti bi PowerShell?

Kif li jżidu punti (par valur ċavetta) għal hashtable ma PowerShell?
$hashtable.Add('Key3', 'Value3')

Kif tikseb valur speċifiku ta ‘hashtable ma PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Kif tikseb il-valur minimu ta ‘hashtable ma PowerShell?

Kif tikseb l-valur massimu ta ‘hashtable ma PowerShell?

Kif timmodifika oġġetti fi hashtable ma PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Kif tneħħi oġġetti fil-hashtable ma PowerShell?
$hashtable.Remove('Key1')

Kif ċar ta ‘hashtable ma PowerShell?
$hashtable.Clear()

Kif biex jiċċekkja l-preżenza ta ‘ċavetta / valur speċifiku fil-hashtable ma PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Kif biex issolvi permezz ewlieni / valur fi hashtable ma PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Kif toħloq firxa vojta ma PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Kif jista ‘jinħoloq firxa ma’ oġġetti bil PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Kif li jżidu punti ma ‘firxa mal PowerShell?
$array += 'D'
[void]$array.Add('D')

Kif timmodifika oġġett fil-firxa ma PowerShell?
$array[0] = 'Z' # 1st item[0]

Kif biex jiċċekkja l-daqs ta ‘firxa mal PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Kif sabiex tkun irkuprata oġġett wieħed / ħafna punti kollha / fil-firxa ma PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Kif tneħħi oġġetti vojta fil-firxa ma PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Kif biex jiċċekkjaw jekk jeżisti oġġett fil-firxa ma PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Kif issib in-numru indiċi ta ‘oġġett fil-firxa ma PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Kif jinqaleb l-ordni ta ‘oġġetti fil-firxa ma PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Kif tiġġenera oġġett każwali minn firxa ma PowerShell?
$array | Get-Random

Kif biex issolvi firxa fi axxendenti / dixxendenti mod ma PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Kif jgħodd in-numru ta ‘oġġetti fil-firxa ma PowerShell?
$array.Count

Kif żid firxa għall-ieħor ma PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Kif issib duplikati minn firxa ma PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Kif tneħħi duplikati minn firxa ma PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Kif jista ‘jinħoloq firxa ma’ oġġetti li tibda bi prefiss (“user01”, “user02”, … “user10”) ma ‘PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Kif lista ACL ta ‘utent AD ma PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Kif li lista ACL ta folder mal PowerShell?
(Get-Acl -Path C:\scripts).Access

Kif telenka iskrizzjonijiet speċifiċi permess ACL (utenti jew gruppi) ta ‘utent AD ma PowerShell?

Up


Variables

Liema huma l-aktar tipi komuni ta ‘dejta ma’ PowerShell?

Kif issib l-valuri minimi u massimi għal xi varjabbli tip ma PowerShell?

Kif biex jittestjaw il-datatype ma PowerShell?

Kif tinħoloq Hawnhekk-String varjabbli ma PowerShell?

Kif tinħoloq varjabbli ma PowerShell?
$powershellGuru = 'Hello'

Kif tinħoloq varjabbli kostanti mal PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Kif tinħoloq varjabbli globali ma PowerShell?
$Global:powershellGuru = 'Hello'

Kif jaqraw varjabbli ma PowerShell?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

Kif biex jiċċekkja l-tip ta ‘varjabbli ma PowerShell?
$powershellGuru.GetType()

Kif issib l-varjabbli fil-kamp ta ‘applikazzjoni globali ma PowerShell?
Get-Variable -Scope Global

Kif tikseb varjabbli speċifiċi bl-isem ma PowerShell?
Get-Variable -Include *Preference -Exclude W*

Kif tassenja tip ta ‘data speċifika għal varjabbli ma PowerShell?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

Kif initialize varjabbli multipli għall-istess valur ma PowerShell?
$a = $b = $c = $d = $e = 0

Dak li huwa l-isem fittizju għall-varjabbli “$ _” ma PowerShell?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

Kif tneħħi fatturi varjabbli ma ‘isem li tibda “għadd” ma PowerShell?
Remove-Variable -Name count*

Kif tikseb l-varjabbli ambjent lokali PowerShell?
Get-ChildItem -Path Env:

Kif tikseb l-Path Ambjentali linja varjabbli b’linja ma PowerShell?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

Kif żid triq ġdida (ex C:. \ SysinternalsSuite) għall-Path Varjabbli Ambjentali mal PowerShell?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

Kif concatenate varjabbli ma PowerShell?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

Kif tuża l-ErrorVariable ma PowerShell?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

Kif tippermetti / jiskonnettja l-ekwivalenti ta ‘”Għażla espliċitu” (VBScript: jeħtieġ li varjabbli tkun iddikjarata) ma PowerShell?

Up


Static .NET Methods

Kif tikseb membri statiċi bil PowerShell?
[DateTime] | Get-Member -Static

Up


Sounds

Kif jilagħbu l-“ħoss” soda mal PowerShell?
[System.Console]::Beep()

Kif jilagħbu l-“asterisk” soda mal PowerShell?
[System.Media.SystemSounds]::Asterisk.Play()

Kif jilagħbu l-“exclamation” soda mal PowerShell?
[System.Media.SystemSounds]::Exclamation.Play()

Kif tikseb ħsejjes disponibbli bil PowerShell?
[System.Media.SystemSounds] | Get-Member -Static

Kif jilagħbu “WAV” ħsejjes bl PowerShell?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
jew
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

Kif jattiva diskors test miktub bl PowerShell?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

Kif jaqraw fajl XML mal PowerShell?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

Kif għall-esportazzjoni data bħala fajl XML mal PowerShell?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

Kif l-importazzjoni data minn fajl CLIXML ma PowerShell?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

Kif tinħoloq GUI bażiku (Windows Form) ma PowerShell?

Up


Characters

Kif jistgħu jikkonvertu l-valur ASCII għal karattru ma PowerShell?
[char]64

Kif jistgħu jikkonvertu karattru tal-valur ASCII ma PowerShell?
[int][char]'@'

Kif tiġġenera l-alfabett Ingliż ma PowerShell?
[char[]](97..122)

Up


Compare

Kif tqabbel żewġ arrays ma PowerShell?

Kif tqabbel żewġ proċessi ma PowerShell?

Up


Microsoft Exchange

Kif sabiex tkun irkuprata l-lista ta ‘apparat mobbli sinkronizzat mal mailbox-utenti ma PowerShell?
Get-ActiveSyncDeviceStatistics

Kif żid “Full aċċess” permessi għal mailbox għal utent ma PowerShell?
Add-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess'

Kif tneħħi “Full aċċess” permessi għal mailbox għal utent ma PowerShell?
Remove-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess' -InheritanceType 'All'

Kif żid “Ibgħat bħala” permessi għal mailbox għal utent ma PowerShell?
Add-ADPermission -Identity $dn -User 'DOMAIN\powershellguru' -ExtendedRights 'Send-As'

Kif tneħħi “Ibgħat bħala” permessi għal mailbox għal utent ma PowerShell?

Kif issib ir-regoli inbox minn mailbox ma PowerShell?
Get-InboxRule -Mailbox 'Powershell.Guru'

Kif tikseb l-indirizz SMTP għall-utenti li jkollhom OWA (Outlook Web Access) ppermettiet il PowerShell?
Get-CASMailbox -Filter{OWAEnabled -eq $true} | Select-Object -Property Name, PrimarySMTPAddress

Exchange 2007

Kif jinstallaw pre-rekwiżiti għal Exchange server Server 2007 Hub Trasport, Mailbox (MBX), u Klijent Aċċess Server (CAS) ma PowerShell?

Exchange 2010

Kif jinstallaw pre-rekwiżiti għal Exchange server Server 2010 Hub Trasport, Mailbox (MBX), u Klijent Aċċess Server (CAS) ma PowerShell?

Exchange 2013

Kif jinstallaw pre-rekwiżiti għal Exchange server Server 2013 Mailbox (MBX) u Klijent Server Aċċess (CAS) ma PowerShell?

Kif jinstallaw pre-rekwiżiti għal Exchange server Server 2013 Server Aċċess Klijent (CAS) biss ma PowerShell?

Up


Microsoft Excel

Kif għall-esportazzjoni u kolonni AutoFit fi fajl Excel bl PowerShell?

Kif biex jiċċekkjaw jekk il-verżjoni Microsoft Office huwa installat ma ‘PowerShell?
$excel = New-Object -ComObject Excel.Application
$excel.Version

Up


Errors

Kif ċar il-“Żball” sistema varjabbli PowerShell?
$Error.Clear()

Kif tikseb l-aħħar eċċezzjoni żball ma PowerShell?
$Error[0].Exception.GetType().FullName

Kif lista l-tipi ta ‘eċċezzjoni ma PowerShell?

Up


PSObject

Kif toħloq oġġetti tad-dwana ma ‘PowerShell?

Up


Openfiles

Kif lista fajls miftuħa mal PowerShell?

Up


Search

Kif tfittex fajls bl PowerShell?

Kif tfittex folders ma ‘PowerShell?