【发布时间】:2011-05-31 19:59:45
【问题描述】:
我正在尝试创建一个将获取计划任务列表的 powershell 脚本。我已经获得了完整的任务列表,但是我需要删除尾随的“...”
你是怎么做到的?
$tasks | Select-String -pattern "Disabled" | ft @{Expression
={$_.Line};Label="Line";width=44}
输出:
Line
----
AD RMS Rights Policy Template Management ...
AD RMS Rights Policy Template Management ...
Proxy ...
UserTask ...
UserTask-Roam ...
Consolidator ...
KernelCeipTask ...
UsbCeip ...
ScheduledDefrag ...
Scheduled ...
Microsoft-Windows-DiskDiagnosticDataColl ...
Microsoft-Windows-DiskDiagnosticResolver ...
Notifications ...
WinSAT ...
ActivateWindowsSearch ...
ConfigureInternetTimeService ...
DispatchRecoveryTasks ...
ehDRMInit ...
InstallPlayReady ...
mcupdate ...
MediaCenterRecoveryTask ...
ObjectStoreRecoveryTask ...
OCURActivate ...
OCURDiscovery ...
PBDADiscovery ...
PBDADiscoveryW1 ...
PBDADiscoveryW2 ...
PeriodicScanRetry ...
PvrRecoveryTask ...
PvrScheduleTask ...
RecordingRestart ...
RegisterSearch ...
ReindexSearchRoot ...
SqlLiteRecoveryTask ...
UpdateRecordPath ...
CorruptionDetector ...
DecompressionFailureDetector ...
HotStart ...
LPRemove ...
SystemSoundsService ...
GatherNetworkInfo ...
Background Synchronization ...
Logon Synchronization ...
AnalyzeSystem ...
RacTask ...
RegIdleBackup ...
WindowsParentalControls ...
WindowsParentalControlsMigration ...
AutoWake ...
GadgetManager ...
SessionAgent ...
SystemDataProviders ...
SR ...
Interactive ...
IpAddressConflict1 ...
IpAddressConflict2 ...
MsCtfMonitor ...
SynchronizeTime ...
ResolutionHost ...
QueueReporting ...
BfeOnServiceStartTypeChange ...
UpdateLibrary ...
ConfigNotification ...
Calibration Loader ...
【问题讨论】:
-
这是答案:但不能提交; $任务 |选择字符串模式“已禁用”| ForEach-Object { $_ -replace "已禁用", ""} | ForEach-Object { $_ -replace "无法启动", ""} | ForEach-Object { $_.Trim() }
标签: string powershell