【免費註冊】 【會員登入】 【個人資料】 【會員列表】 【論壇幫助】 【論壇搜尋】 【登出論壇】

∮Ω奧米加空間∮
∮Ω奧米加空間∮»技術文件區»【推薦】Powershell 筆記

訂覽該主題更新消息 | 將該主題推薦給朋友 發表新主題 發起投票  回覆
作者 主題    
dc
管理員



性別:男
來自:瓦肯星
發表總數:11722
註冊時間:2002-05-07 16:32
(第 1 篇) 【推薦】Powershell 筆記

http://groups.google.com/group/microsoft.public.windows.powershell/topics

---------------------------------------------------------------------------------------------------------
如何刪除包含某字串的行?

假如 C:\789.txt 內容為
============
OddsList 123
not del me
test xml
============
語法

(Get-Content c:\789.txt) | where { $_ -notlike "*OddsList*" -and $_ -notlike "*xml*"}  | set-content c:\789.txt

結果 C:\789.txt 內容為
============
not del me
============



資料來源:microsoft.public.windows.powershell

You can use where-object with the * wildcards.
PS > cat report.txt
\\servername\f$\username\pstfilename
\\servername\sharename\pstfilename
\\servername\username$\pstfilename
PS > cat report.txt | where { $_ -notlike "*f$*" -and $_ -notlike
"*sharename*" }
\\servername\username$\pstfilename

Hope this helps,
Matt
---------------------------------------------------------------------------------------------------------
如何只列出包含某字串的行?

select-string -path d:\abc.log -pattern "https"

資料來源:TechNet最前線




本帖由dc最後編輯於2012-03-08 10:18

Your mind to my mind,

your thought to my thought
發表時間:2012-02-21 15:52
dc的個人資料 傳送郵件給dc dc的個人首頁 dc發表的所有文章 送出悄悄話給dc IP:220.*.*.* 編輯  引言回覆 
dc
管理員



性別:男
來自:瓦肯星
發表總數:11722
註冊時間:2002-05-07 16:32
(第 2 篇) KB968930

KB968930 Windows PowerShell 2.0 與 WinRM 2.0 下載點

Windows XP
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=60cb5b6c-6532-45e0-ab0f-a94ae9ababf5

Windows Vista
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=f2fa1227-9a34-4e29-aa03-62f5c00e16f2

Windows Vista x64
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=0f73efa2-f8d6-45f3-a8f8-5cdc205b119a

Windows Server 2003
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=f002462b-c8f2-417a-92a3-287f5f81407e

Windows Server 2003 x64
http://www.microsoft.com/downloads/zh-tw/details.aspx?familyid=909bbcf1-bd78-4e03-8c83-69434717e551

Win7 與 win 2008 基本上內建

Windows Server 2008
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=863e7d01-fb1b-4d3e-b07d-766a0a2def0b

Windows Server 2008 x64
http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=d37e25cf-db05-4b23-a852-cdf865d81b82






Your mind to my mind,

your thought to my thought
發表時間:2012-04-19 11:01
dc的個人資料 傳送郵件給dc dc的個人首頁 dc發表的所有文章 送出悄悄話給dc IP:59.*.*.* 編輯  引言回覆 
dc
管理員



性別:男
來自:瓦肯星
發表總數:11722
註冊時間:2002-05-07 16:32
(第 3 篇) 【轉貼】powershell 字串處理與編碼方式

資料來源:IT 專業人員的技術資源

小弟在工作上需要應用powershell處理一些文字log,這些文字log的編碼格式是ANSI,當執行 Select-String  -path d:\powershell_test\TEST.log -pattern "LogTest"這樣的命令來搜尋特定字串時,我發現powershell無法搜尋到需要的字串,必須把檔案轉成unicode編碼格式才能搜尋到正確字串,想請教各位高手先進 powershell是否有方法可以對ANSI格式的文字檔案直接進行搜尋字串動作?

找到一種替代的方式可以處理了,使用 gc -encoding string -path d:\powershell_test\TEST.log | select-string "LogTest" 這樣命令就可以直接處理ansi檔案格式,不用轉成unicode格式了,但在搜尋字串上Select-String 還是比較有效率,因此還請各位先進不吝賜教.






Your mind to my mind,

your thought to my thought
發表時間:2012-09-05 13:42
dc的個人資料 傳送郵件給dc dc的個人首頁 dc發表的所有文章 送出悄悄話給dc IP:59.*.*.* 編輯  引言回覆 
遊客



性別:
來自:
發表總數:
註冊時間: 
(第 4 篇) 【原創】

1




發表時間:2014-06-28 22:15
遊客的個人資料 遊客發表的所有文章 送出悄悄話給遊客 IP:197.*.*.* 編輯  引言回覆 
所有時間均為GMT+8, 現在是2026-06-10 10:55    
訂覽該主題更新消息 | 將該主題推薦給朋友 發表新主題 發起投票  回覆

快速回覆
主題 ( 回覆文章可以不輸入標題 )
URLs自動分析
有回覆時郵件通知
禁用表情符號
使用簽名

<聯絡我們 - OMEGA - 控制面板>

Powered by Centaur & Joksky & DC, ver 2003.08.14
Copyright ©2002-2008 PHPY.COM


頁面生成時間:0.0059621334075928