Get-Host
Set-ExecutionPolicy unrestricted
get-member -i $object
$object | get-member
$object | get-member - membertype property
Get-ChildItem . -include *.mdf, *.ndf, *ldf -exclude temp*,auswahl* -recurse -force | sort name | select name, length | Export-Csv \\server\temp\dateiname.csv
Get-ChildItem | % {$Neu = $_.Name; Rename-Item $_.Name -newname $Neu.ToUpper()}
$input = get-content "d:\temp\input.xml"
$output = "d:\temp\output.xml"
if (Test-Path $output) { Remove-Item $output -force}
$input | foreach {
if ($_ -match "Location file://localhost/G:") {
$_ = $_ -replace "file://localhost/G:/xx/yy", "file://server/yy"
$_
}
$_ | out-file $output -append
}
$datei = Get-content C:\temp\datei.txt
$datei | % {
$_
}
(gc $fileName) -replace "pattern", "$&`nText To Add" | sc $fileName
$reader = [System.IO.File]::OpenText("d:\temp\input.xml")
$writer = New-Object System.IO.StreamWriter("d:\temp\output.xml")
while (!$reader.EndOfStream) {
$line = $reader.ReadLine()
if ($line -match "Location file://localhost/G:") {
$line = $line -replace "file://localhost/G:/xx/yy", "file://server/yy"
$line
}
$writer.writeline($line)
}
$reader.Close()
$writer.Close()
| | ft -autosize | Out-String -Width 4096
cat .\input.txt | % {$_ -replace ".txt:",".txt "}
Import-Csv .\output.txt -delimiter ' ' | sort date, time -desc | select -first 1 | ft
@echo off
set suchip=%1
if %1=="" exit 0
echo logfile date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken> i:\temp\check_ip.txt
findstr /s /i /c:"%suchip%" \\server1\c$\logs\iis\*.* >> c:\temp\check_ip.txt
findstr /s /i /c:"%suchip%" \\server2\c$\logs\iis\*.* >> c:\temp\check_ip.txt
findstr /s /i /c:"%suchip%" \\server3\c$\logs\iis\*.* >> c:\temp\check_ip.txt
findstr /s /i /c:"%suchip%" \\server4\c$\logs\iis\*.* >> c:\temp\check_ip.txt
select-string -path c:\logs\*.txt -pattern "192\.168\.17\.54(.)*207\.68\.172\.246" -allmatches | ft filename,linenumber,@{"Label"="Time";"Expression"={$_.line.replace($_.matches[0],"")}} –auto
Send-MailMessage -to "heinz.name@mailserver.de" -from "hertha.name@mailserver.de" -subject "Testmail" -SmtpServer smtp.server.de
Select-String -Path C:\temp\*.log -Pattern "Contoso"
oder rekursiv:
Get-ChildItem C:\temp -Filter *.log -Recurse | Select-String "Contoso"
Get-Content -Path log.txt -tail 1
Get-Content -Path log.txt -wait
[regex]::match(“$zeile”,'[^\\]+’).value
[regex]::replace("$zeile",'^.*[\\\/]','')
Set-Location Cert:\LocalMachine\My
$jetzt = Get-Date -Format "dd.MM.yyyy hh:mm:ss"
Get-ChildItem | foreach {
$Diff = New-TimeSpan -Start $jetzt -End $_.GetExpirationDateString()
if ($Diff.Days -lt 50) {$Diff.Days}
}
function GetNextArrayIndex {
param
(
$iMax,
[ref]$iNdex
)
if ($iNdex.Value -ge $iMax-1) {
$iNdex.Value = 0
}
else {
$iNdex.Value ++
}
return $iNdex.Value
}
$ContentDBs = @("DB01","DB02","DB03","DB04")
$AI = -1
For ($i = 0; $i -lt 100; $i++) {
$ContentDBs[(GetNextArrayIndex -iMax $ContentDBs.Count -iNdex ([ref]$AI))]
}
Get-content "c:\quell.txt" | sort | get-unique | out-file "c:\ziel.txt"