Blog
Hier poste ich dinge zu Themen die mich beschäftigten.
Suchen
2024-12-07
Own hosting - all what you need
StartOS is an open-source Linux distribution developed by Start9 Labs, designed to simplify self-hosting services on personal servers. [Mehr lesen…]
Admin - 13:11:17 @ Projekte | Kommentar hinzufügen
2024-03-08
PHP: sende Mail
<?php
if ($_SERVER[”REQUEST_METHOD”] == “POST”) {
// Empfänger-E-Mail-Adresse
$empfaenger = “Mustermann@domain”;
// Betreff der E-Mail
$betreff = “Neue Kontaktanfrage von ” . [Mehr lesen…]
Admin - 09:56:52 @ Projekte | Kommentar hinzufügen
Powershell: gruppename like finden und aktivierte user zaehlen
$groups = Get-ADGroup -Filter ‘Name -like “*-Users”‘
foreach ($group in $groups) {
# Get the members of each group
$members = Get-ADGroupMember -Identity $group -Recursive | Get-ADUser -Property Enabled | Where-Object {$_.Enabled -eq $true}
# Output the count of enabled members
Write-Output “Group: $($group.Name) has $($members.Count) enabled members”
}
Admin - 09:54:54 @ Projekte, Powershell-Skripte | Kommentar hinzufügen
2024-03-04
HW und SW auslesen und exportieren
# Zentralen DFS-Share Pfad definieren
$dfsShare = “C:tmpAusgabe”
# Überprüfen, ob der DFS-Share Pfad existiert
if (-not (Test-Path -Path $dfsShare)) {
Write-Host “Der DFS-Share Pfad existiert nicht.”
exit
}
$computerName = $env:COMPUTERNAME
$hwOutputPath = Join-Path -Path $dfsShare -ChildPath ($computerName + “_HW.csv”)
$swOutputPath = Join-Path -Path $dfsShare -ChildPath ($computerName + “_SW.csv”)
try {
# Computerinformationen sammeln
$computerInfo = Get-ComputerInfo
$computerInfoProperties = $computerInfo | Get-Member -MemberType Property | Select-Object -ExpandProperty Name
# Formatierung und Export der Computerinformationen
$formattedComputerInfo = @()
foreach ($prop in $computerInfoProperties) {
$value = $computerInfo.$prop
# Beispiel für eine spezifische Formatierung (weitere Bedingungen können hinzugefügt werden)
if ($prop -like “*Memory*”) {
$value = [Math]::Round($value / 1GB, 2)
}
$formattedComputerInfo += New-Object psobject -Property @{
Property = $prop
Value = $value
}
}
$formattedComputerInfo | Export-Csv -Path $hwOutputPath -NoTypeInformation -Force
# Softwareinformationen sammeln und formatieren
$softwareInfo = Get-WmiObject -Class Win32_Product | ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
Version = $_.Version
Vendor = $_.Vendor
}
}
# Softwareinformationen in CSV exportieren
$softwareInfo | Export-Csv -Path $swOutputPath -NoTypeInformation -Force
} catch {
Write-Host “Fehler beim Sammeln oder Schreiben der Systeminformationen.”
}
Admin - 16:36:37 @ Projekte, Powershell-Skripte | Kommentar hinzufügen
Angeschlossene Monitore auslesen
function Get-MonitorInfo {
$MonitorInfo = Get-WmiObject WmiMonitorID -Namespace rootwmi -ComputerName $env:COMPUTERNAME
$Output = @()
$SeenSerials = @()
foreach ($Monitor in $MonitorInfo) {
$Serial = ($Monitor.SerialNumberID -notmatch ‘^0$’ | ForEach-Object {[char]$_}) -join “”
if ($SeenSerials -contains $Serial) {
continue
}
$SeenSerials += $Serial
$Manufacturer = ($Monitor.ManufacturerName -notmatch ‘^0$’ | ForEach-Object {[char]$_}) -join “”
$Name = ($Monitor.UserFriendlyName -notmatch ‘^0$’ | ForEach-Object {[char]$_}) -join “”
$Output += “Manufacturer: $Manufacturer`nName: $Name`nSerial: $Serial`n”
}
return $Output
}
# Überprüfen des IP-Bereichs vor der Ausführung
$CurrentIP = (Get-NetIPAddress -AddressFamily IPv4).IPAddress
$AllowedIPRange = “192.168.200.*” # Beispiel-IP-Bereich, anpassen nach Bedarf
if ($CurrentIP -like $AllowedIPRange) {
cls
$MonitorInfo = Get-MonitorInfo
# Definieren des Freigabepfads und Erstellen des Dateinamens
$SharedPath = “c:tmp” # Anpassen an Ihren Freigabepfad
$Date = Get-Date -Format “yyyyMMdd”
$FileName = “MonitorInfo_$Date” + “_” + $env:COMPUTERNAME + “.txt”
$FullFilePath = Join-Path -Path $SharedPath -ChildPath $FileName
# Schreiben der Informationen in die Datei im Freigabepfad
$MonitorInfo | Out-File -FilePath $FullFilePath
# Optionale Ausgabe zur Bestätigung
Write-Host “Monitor information saved to $FullFilePath”
} else {
Write-Host “This script is not allowed to run in the current IP range.”
}
Admin - 16:29:45 @ Projekte, Powershell-Skripte | Kommentar hinzufügen