随笔分类 - Powershell--System Management
摘要:PS C:\WINDOWS\system32> $ssids SSID 1 : vo_BSSID 1 : 08:e8:4f:fc:05:80_SSID 2 : VIPGuest_BSSID 1 : bc:67:1c:58:08:72_SSID 3 : ve鐨刬Mac_BSSID 1 : b8:09:
阅读全文
摘要:转自:http://sodaxu.blog.51cto.com/8850288/1417385
阅读全文
摘要:cd C:\Eventlog$gap = (Get-Date) - (New-TimeSpan -Days 365)$unusedfiles = Get-ChildItem | where -FilterScript {$_.lastwritetime -lt $gap -and $_.name -...
阅读全文
摘要:$source = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Carbon"$target = "\c$\Windows\System32\WindowsPowerShell\v1.0\Modules"$ON_OFF = Import-C...
阅读全文
摘要:Hostname,IP,OSTypesrv1,10.103.22.22,Win2003srv2,10.103.22.37,Win2008Import-Csv -Path F:\chgpwd\APACHost.CSV | ForEach-Object { "**************" + $...
阅读全文
摘要:(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection("\\cnhzsrv06apac\cnhzprn02") 结合计划任务开机部署打印机: 2014-03-29T16:30:35.8220999 A7...
阅读全文
摘要:$shell = New-Object -ComObject WScript.Shell$desktop = [System.Environment]::GetFolderPath('Desktop')$shortcut = $shell.CreateShortcut("$desktop\Smart...
阅读全文
摘要:$c = Get-WmiObject -Class Win32_LogicalDisk | where {$_.size} | select-object -Property deviceid, @{N='Free';E={[System.Math]::round($_.freespace / $_.size * 100)}} | Where-Object -FilterScript {$_.d...
阅读全文
摘要:(Get-WmiObject -class Win32_UserAccount | where {$_.SID -Like 'S-1-5-*-500'}).Rename("Ultraman")
阅读全文
摘要:$parttern = "\b\d{6}\b"$today = Get-Date$hostname = "cnhzpd-47d173x"$profiles = Get-WmiObject -Class win32_userprofile -ComputerName $hostname | Selec...
阅读全文
摘要:# 这个月的第一天#..........................................到这里之前是取当年第一天#(Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month - 2)# 这个月的最后一天#...
阅读全文
摘要:#Test-Connection, 之所以不采用这种方法, 是因为该命令对于丢包返回系统报错, 无法被抓取.$end = [datetime]"2015年4月27日 20:32:20"$start = Get-Date$count = [math]::Round(($end - $start).To...
阅读全文
摘要:#列出一个文件夹下所有文件的信息Get-ChildItem -Path F:\BCP -Recurse | Where-Object {$_.mode -Like "-*"} | Select-Object -Property FullName, Length | Export-Csv -Path ...
阅读全文
摘要:$source = "c:\XXX.XXX"$pw = ConvertTo-SecureString '密码' -AsPlainText -Force$Creds = New-Object -Typename System.Management.Automation.PSCredential -Ar...
阅读全文
摘要:2015-4-6写的代码(Dell), 不知道如何对报错进行友好化处理,于是采用了"非空"和"非空的补集"处理方式. 2015-4-21写的代码(Dell), 含Try, Catch, Finally用法 2015-5-4写的代码(Lenovo) 2015-5-4写的代码(Dell & Lenovo
阅读全文
摘要:Dell: Rename-Computer -NewName ("CNHZPD-" + (Get-WmiObject -class win32_Bios).SerialNumber.substring(0,7)) -RestartLenovo:$parttern_ln="\b\D{2}\d{8}\b...
阅读全文
摘要:#三种方法,由初级到高级$numbers = 1..40 | Foreach {"{0:D3}" -f $_} #将数字类型格式化并转换为字符串类型使用-f字符串操作符 ForEach ($number in $numbers) { $Source = 'http://definitions.symantec.com/defs/' + ((Get-Date -Format yyyyMMdd) -...
阅读全文
摘要:$report = [pscustomobject]@{'Date' = $null; 'MSRC' = $null; 'KB' = $null; 'Severity' = $null; 'Version' = $null; 'Summary' = $null; 'ThreatType' = $null} $report | Export-Csv -Path E:\PatchReport.csv...
阅读全文
浙公网安备 33010602011771号