随笔分类 -  CMD and PowerShell

一些关于DOS命令和PowerShell的comlet的知识
用Powershell强制同步Windows主机与Internet time server的时间
摘要:第一步,判断Windows Time服务是否正在运行,如果没有,则开启它。第二步,强制同步,不知为何,往往第一次会失败,那么就多运行几次好了。Get-Service w32time | Where {$_.status –eq 'Stopped'} | Start-ServiceW32tm /resync /forceW32tm /resync /force参考资料==========https... 阅读全文

posted @ 2019-05-07 11:04 中道学友 阅读(1344) 评论(0) 推荐(0) 编辑

断开所有的SMB连接的批处理
摘要:备用@ECHO OFFECHO ===Check how many SMB shares that already connected===net useECHO ===Disconnect them all without asking for permission===net use * /D /yECHO ===Hit Enter to continue===set /p DUMMY=Hit... 阅读全文

posted @ 2017-12-14 09:46 中道学友 阅读(1317) 评论(0) 推荐(0) 编辑

批处理只执行第一句,其他的不被执行,怎么办?
摘要:我写了一个批处理来配置Windows的PowerShell Remote,脚本如下: winrm quickconfig -quietwinrm set winrm/config/service/auth @{Basic="true"}winrm set winrm/config/service @{AllowUnencrypted="true"}winrm set winrm/confi... 阅读全文

posted @ 2017-03-09 11:21 中道学友 阅读(2450) 评论(0) 推荐(0) 编辑

PowerShell remoting中的second-hop问题
摘要:一直以来都对powershell remote有点一知半解, 今天通过这个问题的解决, 理解加深了好多. 下文写的挺清楚的, 保留在这里. Using CredSSP for second-hop PowerShell remoting https://4sysops.com/archives/using-credssp-for-second-hop-powershell-remoti... 阅读全文

posted @ 2016-12-27 18:16 中道学友 阅读(306) 评论(0) 推荐(0) 编辑

什么是automatic variable?
摘要:看代码符号$?搞不清楚是什么? 看代码. $share = Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credential $credentials -Filter "Description='Default share'" if($?) { "command succeeded" $sha... 阅读全文

posted @ 2016-08-15 16:35 中道学友 阅读(902) 评论(0) 推荐(1) 编辑

批量替换文件名中的某个字符串的小脚本
摘要:有需求, 就自己写一个玩玩. Get-ChildItem -Path F:\MyFolder -Filter *.m4a | ForEach-Object { $newname = $_.Name -replace "something","somethingelse" Rena... 阅读全文

posted @ 2016-02-18 11:32 中道学友 阅读(3611) 评论(0) 推荐(0) 编辑

[PowerShell Utils] Create a list of virtual machines based on configuration read from a CSV file in Hyper-V
摘要:Hello everyone, this is the third post of the series. . Background =============== In my solution, I have 15 Windows hosts. I need to configure them from the OS installation to configure fail ov... 阅读全文

posted @ 2015-11-25 15:53 中道学友 阅读(425) 评论(0) 推荐(0) 编辑

[PowerShell Utils] Remotely install Hyper-V and Failover Cluster feature on a list of windows 2012 servers
摘要:Hello everyone, this is the second post of the series. . Background =============== In my environment, I have 15 Windows hosts. I need to configure them from the OS installation to configure fai... 阅读全文

posted @ 2015-11-24 12:57 中道学友 阅读(478) 评论(0) 推荐(0) 编辑

[PowerShell Utils] Automatically Change DNS and then Join Domain
摘要:I would like to start a series of blog posts sharing PowerShell scripts to speed up our solution operations. Today, I am going to share a script file that can select a network adapter, changes its DN... 阅读全文

posted @ 2015-11-24 12:53 中道学友 阅读(350) 评论(0) 推荐(0) 编辑

开启Remote Desktop的PowerShell
摘要:1) Enable Remote Desktop set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0 2) 在firewall允许RDP进入 Enable-NetFirewallRule -Displa... 阅读全文

posted @ 2015-06-03 15:42 中道学友 阅读(717) 评论(0) 推荐(0) 编辑

如何远程运行PowerShell命令?
摘要:首先, 被remote运行PowerShell的windows必须已经join了domain. 其次, 该Windows的PowerShell必须开启对remote command的接受, 运行下面的命令来做到: enable-psremoting 示例如下: 好了, 可以到另一台机器上去执行命令玩玩看啦. 运行Enter-PSSession命令来执行远程命令. Enter-PSSess... 阅读全文

posted @ 2015-06-03 15:21 中道学友 阅读(637) 评论(0) 推荐(0) 编辑

重启Windows的PowerShell
摘要:这么简单的一个命令都单独写一篇blog, 是不是太无耻了? 好吧, 谁让咱不会呢. 学会了就来一篇. 呵呵. Restart-Computer 来源 ================ http://www.computerperformance.co.uk/powershell/powershell_restart_computer.htm 阅读全文

posted @ 2015-06-03 15:07 中道学友 阅读(2677) 评论(0) 推荐(0) 编辑

让Windows加入域的PowerShell
摘要:$domain = "midrange.lab" $password = "MyPassword!" | ConvertTo-SecureString -asPlainText -Force $username = "$domain\administrator" $credential = New-Object System.Management.Automat... 阅读全文

posted @ 2015-06-03 15:00 中道学友 阅读(3335) 评论(0) 推荐(0) 编辑

关掉Windows Firewall的PowerShell
摘要:在Windows 8或Windows 2012 R2上, 使用下面的命令: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False 在更早版本的Windows上, 使用netsh命令: netsh advfirewall set allprofiles state on 资料来源 ==... 阅读全文

posted @ 2015-06-03 14:49 中道学友 阅读(1072) 评论(0) 推荐(0) 编辑

修改IP地址的PowerShell
摘要:$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'" $wmi.EnableStatic("10.0.0.15", "255.255.255.0") $wmi.SetGateways("10.0.0.1", 1) $wmi.SetDNSServerSearchO... 阅读全文

posted @ 2015-06-03 14:43 中道学友 阅读(2819) 评论(0) 推荐(0) 编辑

如何得知当前机器上安装的PowerShell是什么版本的?
摘要:$PSVersionTable.PSVersion 参考资料 ================ http://stackoverflow.com/questions/1825585/determine-installed-powershell-version http://blogs.technet.com/b/heyscriptingguy/archive/2014/10/13/p... 阅读全文

posted @ 2015-06-03 14:14 中道学友 阅读(341) 评论(0) 推荐(0) 编辑

在CMD下如何搜索某个名字的文件?
摘要:命令如下: dir FileYouWantToFind.txt /a /s 效果如图: 偷看Kun总操作学来的 ^_^ 阅读全文

posted @ 2014-06-20 15:26 中道学友 阅读(2530) 评论(0) 推荐(0) 编辑

如何获得Windows Server 2012上的FC的WWN
摘要:我有一个测试环境, 一对Host与storage array之间既有iSCSI的连接, 也有FC的连接. 原来iSCSI的连接是OK的, 现在需要转用FC. 当在光纤交换机上划好了Zone之后, storage上显示了四条路径已通, 但是究竟哪两个才是属于具体的某一台主机呢? 经过搜索, 找到文章Find HBA and WWN Information on Windows using... 阅读全文

posted @ 2014-01-22 15:15 中道学友 阅读(5981) 评论(0) 推荐(0) 编辑

PowerShell中的一个switch的例子
摘要:在这个例子中, 应该注意 Switch语句里对数字范围条件的使用 break的使用 字符串的拼接 数组的声明 $array = @(1,6,7,8,11,15,16)foreach ($element in $array){ switch($element) { {$_ -le 5} {Write-Host $($element.ToS... 阅读全文

posted @ 2013-06-26 13:52 中道学友 阅读(1586) 评论(0) 推荐(0) 编辑

创建FileShare的content source的SharePoint 2013的powershell脚本
摘要:Add-PSSnapin "Microsoft.SharePoint.PowerShell"#Get SSA and then create a new content source$SSA = Get-SPEnterpriseSearchServiceApplication -Identity "SSA" New-SPEnterpriseSearchCrawlContentSource -Se... 阅读全文

posted @ 2013-06-07 14:36 中道学友 阅读(225) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

技术追求准确,态度积极向上

点击右上角即可分享
微信分享提示