Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ping_response = 0
- # testime ühendust TLNCM01-ga, et skript ei üritaks csv-d exportida ühenduse puudumisel
- while ($ping_response -eq 0) {
- # kui TLNCM01 ei pingi, proovime 5 sekundi pärast uuesti
- if ((Test-Connection tlncm01.energia.sise -quiet) -ne $True) {
- Write-Output "TLNCM01 ei ole hetkel k2ttesaadav"
- Start-Sleep -Seconds 5
- } else {
- # välistame kasutajad, mida me ei taha
- $users = Get-ChildItem c:\users | Where-Object -FilterScript {$_.Name -notlike "*default*" -And $_.Name -ne "Public" -And $_.Name -notlike "*admin*"}
- # loobime kõik kasutajad läbi, välistame W7 peal olevad mingid naljakad default favorited
- $csv = foreach ($user in $users) {
- if (Test-Path "C:\users\$user\favorites") {
- $favs = Get-ChildItem c:\users\$user\favorites -Recurse | Where-Object -FilterScript {$_.Name -ne "Links" `
- -And $_.Name -ne "Bing.url" -And $_.Name -ne "Web Slice Gallery.url" -And $_.Name -ne "Suggested Sites.url" -And $_.Name -ne "ITABI.url" `
- -And $_.Name -notlike "*MSN*" -And $_.Name -notlike "*Windows*" -And $_.Name -notlike "*Microsoft*" -And $_.Name -notlike "*IE Add-on*"}
- "string" | Select-Object @{N='PC';E={$env:computername}}, @{N='User';E={$user}}, @{N='URL count';E={($favs | measure-object).count}}
- } else {
- }
- }
- # ekspordime kogutud info csv-na välja
- if ($csv -ne $null) {
- $csv | export-csv "\\tlncm01\Inventuur$\favorites\$env:computername.csv" -UseCulture -NoTypeInformation
- Write-Output "CSV eksporditud"
- } else {
- Write-Output "Kasutajate favorites kaustad puuduvad v6i on tyhjad"
- }
- $ping_response = 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement