我需要从例如my.file.xlsx中提取文件名和扩展名.我不知道文件或扩展名的名称,名称中可能有更多的点,所以我需要从右边搜索字符串,当我找到第一个点(或从左边开始)时,提取部分右侧和该点左侧的部分.
也许有更好的解决方案,但我在这里或其他地方找不到任何东西.谢谢
我有这个单行:
get-WmiObject win32_logicaldisk -Computername remotecomputer
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
DeviceID : A:
DriveType : 2
ProviderName :
FreeSpace :
Size :
VolumeName :
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 20116508672
Size : 42842714112
VolumeName :
DeviceID : D:
DriveType : 5
ProviderName :
FreeSpace :
Size :
VolumeName :
Run Code Online (Sandbox Code Playgroud)
如何获得Freespace和Size的DeviceID C:?我需要提取这两个值而没有其他信息.我用Selectcmdlet 尝试过,但没有效果.
编辑: 我只需要提取数值并将它们存储在变量中.
我有这个powershell脚本来发送附件的电子邮件,但是当我添加多个收件人时,只有第一个收到邮件.我已经阅读了文档,仍然无法弄明白.谢谢
$recipients = "Marcel <marcel@turie.eu>, Marcelt <marcel@nbs.sk>"
Get-ChildItem "C:\Decrypted\" | Where {-NOT $_.PSIsContainer} | foreach {$_.fullname} |
send-mailmessage -from "primasfrb@nbs.sk" `
-to "$recipients" `
-subject "New files" `
-body "$teloadmin" `
-BodyAsHtml `
-priority High `
-dno onSuccess, onFailure `
-smtpServer 192.168.170.61
Run Code Online (Sandbox Code Playgroud) 我在Facebook评论插件的网页上使用Facebook按钮,直到现在它的工作原理为oK.今天我意识到它在三种不同的浏览器中以三种不同的语言(英语,捷克语和斯洛伐克语)显示.问题在于每种语言的宽度不同.在这里,我尝试将en_US更改为sk,但没有效果:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
Run Code Online (Sandbox Code Playgroud) 我有这个脚本来比较两个文件夹.
$firstfolder = Get-ChildItem C:\firstfolder
$secondfolder = Get-ChildItem C:\firstfolder
if ($firstfolder -eq $secondfolder) {
Write-Host "Folders are the same."
} else {
Write-Host "Error: Doesn't match."
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我比较了同一个文件夹.问题是,它永远不会考虑,数组是相等的.为什么?
每当我的脚本没有正确结束并且没有执行stop-transcript时,我会收到此消息:
Start-Transcript : Transcription has already been started. Use the stop-transcr
ipt command to stop transcription.
At C:\ps\003desifrovanie.ps1:4 char:17
+ start-transcript <<<< -path c:\_LOG\sfrbdesifrovanie.log -append
+ CategoryInfo : NotSpecified: (:) [Start-Transcript], InvalidOpe
rationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power
Shell.Commands.StartTranscriptCommand
Run Code Online (Sandbox Code Playgroud)
是否可以检查脚本是否正在运行并使用if-then在脚本开始时停止?或者如何在结束时可靠地阻止它?谢谢
我尝试使用sort-object cmdlet按Id在此处对进程进行排序:
Get-Process | Sort-Object -Property Id
Run Code Online (Sandbox Code Playgroud)
而且运作良好.在我发现的任何其他示例中,排序工作正常,但是当我尝试使用这个单行程序从Active Directory中的employeeID对员工进行排序时:
Get-QADUser -IncludeAllProperties -SerializeValues | ? {?_.Mail} | select employeeID | sort-object -property employeeID
Run Code Online (Sandbox Code Playgroud)
我得到这样的东西:
11 1104 1105 1185 119 12 ...
我有这个:
(Get-WMIObject Win32_logicaldisk -computername computer).TotalPhysicalMemory
Run Code Online (Sandbox Code Playgroud)
获取远程计算机上安装的物理内存的大小.如何获得该计算机的免费内存?
我试过了
(Get-WMIObject Win32_logicaldisk -computername computer).FreePhysicalMemory
Run Code Online (Sandbox Code Playgroud)
和其他一些变种,但没有效果.是否有一些可能的"过滤器"列表?
在我们公司,我们使用Windows应用程序生成word(2010)文档.有时候文档没有正确关闭,所以另一个应用程序(是的,他们仍然称之为开发:)杀掉运行超过1分钟的单词进程.
这些被杀死的进程存储在MS Word的"文档恢复"中.在Word 2010中无法关闭这些文档恢复(选项/"保存自动回复信息..."无法解决问题).当这些"文档恢复"中充满了文档(数十或数百)时,应用程序停止生成文档,我们需要手动清除前端.
所以,我能够编写这个脚本来识别并杀死运行超过10秒的进程,但有没有办法如何正确关闭它(不杀死它)?
我发现本教程使用powershell创建和退出word文档,但如何将特定的word进程与这些MS Office方法连接以关闭文档?
$timer = 10
$date = Get-Date
if (Get-Process winword*) {
Get-Process winword | foreach {
if ((($date - $_.StartTime).Seconds) -gt $timer) {
$procID = $_.id
Write-Host -ForegroundColor Magenta "Process $procID is running longer than $timer seconds."
Write-Host -ForegroundColor Green "Killing process $procID.."
Stop-Process $procID
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
这可能是个愚蠢的问题,但我找不到答案.如何用css设置echo输出的样式?我有这个代码:
echo "<div id="errormsg"> Error </div>";
Run Code Online (Sandbox Code Playgroud)
现在它显示语法错误,我认为是因为有关errormsg的引用.我试过单引号,但没有效果.谢谢
powershell ×8
.net ×2
css ×1
facebook ×1
javascript ×1
ms-word ×1
php ×1
quest ×1
scripting ×1
windows ×1