{"id":302,"date":"2012-04-19T10:33:00","date_gmt":"2012-04-19T07:33:00","guid":{"rendered":"http:\/\/blog.successionua.com\/?p=302"},"modified":"2012-04-19T10:33:00","modified_gmt":"2012-04-19T07:33:00","slug":"%d1%83%d0%b4%d0%b0%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b8-%d0%b0%d1%80%d1%85%d0%b8%d0%b2%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d0%b5-%d1%84%d0%b0%d0%b9%d0%bb%d0%be%d0%b2-%d0%b2-windows-2003-%d1%81","status":"publish","type":"post","link":"https:\/\/geckich.space\/?p=302","title":{"rendered":"\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Windows 2003 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PowerShell"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043c\u0430\u0441\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u0451 \u0447\u0435\u0440\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \ud83d\ude42<\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0441\u044f\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c &#8211; \u0430\u0440\u0445\u0438\u0432 \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438 \u0431\u044b\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u043e\u043c&#8230; \u0422. \u0435. \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u044f New-Item \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b, \u043d\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 &#8211; \u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0434\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u0443\u0442\u0438 (\u0447\u0442\u043e\u0431\u044b \u043b\u0435\u0433\u0447\u0435 \u0431\u044b\u043b\u043e \u043c\u0435\u043d\u044f\u0442\u044c &#8220;\u043f\u043e\u0434 \u0441\u0435\u0431\u044f&#8221;), \u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u043e), \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #999999; font-style: italic;\">####### define parameters<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- get current date ----#<\/span><br \/><span style=\"color: #40ffff;\">$Now<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #24909d;\">Get-Date<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define amount of days ----#<\/span><br \/><span style=\"color: #40ffff;\">$Days<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"10\"<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define folder where files are located ----#<\/span><br \/><span style=\"color: #40ffff;\">$TargetFolder<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"C:gbQuoteServer\"<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define LastWriteTime parameter based on $Days ---#<\/span><br \/><span style=\"color: #40ffff;\">$LastWrite<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #40ffff;\">$Now<\/span><span style=\"color: #d0d0d0;\">.AddDays(-<\/span><span style=\"color: #40ffff;\">$Days<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define delete list file path<\/span><br \/><span style=\"color: #40ffff;\">$Del_List<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"c:scriptsfiles.txt\"<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define files fore archiving list file path ---#<\/span><br \/><span style=\"color: #40ffff;\">$Arch_List<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"c:scriptsarchive.txt\"<\/span><br \/><span style=\"color: #999999; font-style: italic;\">#----- define archive file path - this file MUST exist! ---#<\/span><br \/><span style=\"color: #40ffff;\">$Arch_Path<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"c:scriptstest.zip\"<\/span><br \/><span style=\"color: #999999; font-style: italic;\">####### archiving part<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">foreach<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$_<\/span> <span style=\"color: #6ab825; font-weight: bold;\">in<\/span> <span style=\"color: #24909d;\">Get-Content<\/span> <span style=\"color: #40ffff;\">$Arch_List<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/><span style=\"color: #d0d0d0;\">{<\/span><br \/><span style=\"color: #40ffff;\">$Files<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #24909d;\">Get-Childitem<\/span> <span style=\"color: #40ffff;\">$TargetFolder<\/span> <span style=\"color: #d0d0d0;\">-Include<\/span> <span style=\"color: #40ffff;\">$_<\/span> <span style=\"color: #d0d0d0;\">-Recurse<\/span> <span style=\"color: #d0d0d0;\">|<\/span> <span style=\"color: #d0d0d0;\">Where<\/span> <span style=\"color: #d0d0d0;\">{<\/span><span style=\"color: #40ffff;\">$_<\/span><span style=\"color: #d0d0d0;\">.LastWriteTime<\/span> <span style=\"color: #d0d0d0;\">-le<\/span> <span style=\"color: #ed9d13;\">\"$LastWrite\"<\/span><span style=\"color: #d0d0d0;\">}<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">foreach<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$File<\/span> <span style=\"color: #6ab825; font-weight: bold;\">in<\/span> <span style=\"color: #40ffff;\">$Files<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/>    <span style=\"color: #d0d0d0;\">{<\/span><br \/>    <span style=\"color: #6ab825; font-weight: bold;\">if<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$File<\/span> <span style=\"color: #d0d0d0;\">-ne<\/span> <span style=\"color: #40ffff;\">$NULL<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/>        <span style=\"color: #d0d0d0;\">{<\/span><br \/>        <span style=\"color: #24909d;\">write-host<\/span> <span style=\"color: #ed9d13;\">\"Archiving File $File\"<\/span> <span style=\"color: #d0d0d0;\">-ForegroundColor<\/span> <span style=\"color: #ed9d13;\">\"Green\"<\/span><br \/>        <span style=\"color: #40ffff;\">$ZipFile<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #24909d;\">new-object<\/span> <span style=\"color: #d0d0d0;\">-com<\/span> <span style=\"color: #d0d0d0;\">shell.application).NameSpace(<\/span><span style=\"color: #40ffff;\">$Arch_Path<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/>  <span style=\"color: #40ffff;\">$ZipFile<\/span><span style=\"color: #d0d0d0;\">.CopyHere(<\/span><span style=\"color: #40ffff;\">$_<\/span><span style=\"color: #d0d0d0;\">.fullname)<\/span><br \/>        <span style=\"color: #d0d0d0;\">}<\/span><br \/>    <span style=\"color: #6ab825; font-weight: bold;\">else<\/span><br \/>        <span style=\"color: #d0d0d0;\">{<\/span><br \/>        <span style=\"color: #24909d;\">Write-Host<\/span> <span style=\"color: #ed9d13;\">\"No more files to archive!\"<\/span> <span style=\"color: #d0d0d0;\">-foregroundcolor<\/span> <span style=\"color: #ed9d13;\">\"Green\"<\/span><br \/>        <span style=\"color: #d0d0d0;\">}<\/span><br \/>    <span style=\"color: #d0d0d0;\">}<\/span><br \/><span style=\"color: #d0d0d0;\">}<\/span><br \/><br \/><span style=\"color: #999999; font-style: italic;\">####### deleting part<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">foreach<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$_<\/span> <span style=\"color: #6ab825; font-weight: bold;\">in<\/span> <span style=\"color: #24909d;\">Get-Content<\/span> <span style=\"color: #40ffff;\">$Del_List<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/><span style=\"color: #d0d0d0;\">{<\/span><br \/><span style=\"color: #40ffff;\">$Files<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #24909d;\">Get-Childitem<\/span> <span style=\"color: #40ffff;\">$TargetFolder<\/span> <span style=\"color: #d0d0d0;\">-Include<\/span> <span style=\"color: #40ffff;\">$_<\/span> <span style=\"color: #d0d0d0;\">-Recurse<\/span> <span style=\"color: #d0d0d0;\">|<\/span> <span style=\"color: #d0d0d0;\">Where<\/span> <span style=\"color: #d0d0d0;\">{<\/span><span style=\"color: #40ffff;\">$_<\/span><span style=\"color: #d0d0d0;\">.LastWriteTime<\/span> <span style=\"color: #d0d0d0;\">-le<\/span> <span style=\"color: #ed9d13;\">\"$LastWrite\"<\/span><span style=\"color: #d0d0d0;\">}<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">foreach<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$File<\/span> <span style=\"color: #6ab825; font-weight: bold;\">in<\/span> <span style=\"color: #40ffff;\">$Files<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/>    <span style=\"color: #d0d0d0;\">{<\/span><br \/>    <span style=\"color: #6ab825; font-weight: bold;\">if<\/span> <span style=\"color: #d0d0d0;\">(<\/span><span style=\"color: #40ffff;\">$File<\/span> <span style=\"color: #d0d0d0;\">-ne<\/span> <span style=\"color: #40ffff;\">$NULL<\/span><span style=\"color: #d0d0d0;\">)<\/span><br \/>        <sp\nan style=\"color: #d0d0d0;\">{<\/span><br \/>        <span style=\"color: #24909d;\">write-host<\/span> <span style=\"color: #ed9d13;\">\"Deleting File $File\"<\/span> <span style=\"color: #d0d0d0;\">-ForegroundColor<\/span> <span style=\"color: #ed9d13;\">\"DarkRed\"<\/span><br \/>        <span style=\"color: #24909d;\">Remove-Item<\/span> <span style=\"color: #40ffff;\">$File<\/span><span style=\"color: #d0d0d0;\">.FullName<\/span> <span style=\"color: #d0d0d0;\">|<\/span> <span style=\"color: #24909d;\">out-null<\/span><br \/>        <span style=\"color: #d0d0d0;\">}<\/span><br \/>    <span style=\"color: #6ab825; font-weight: bold;\">else<\/span><br \/>        <span style=\"color: #d0d0d0;\">{<\/span><br \/>        <span style=\"color: #24909d;\">Write-Host<\/span> <span style=\"color: #ed9d13;\">\"No more files to delete!\"<\/span> <span style=\"color: #d0d0d0;\">-foregroundcolor<\/span> <span style=\"color: #ed9d13;\">\"Green\"<\/span><br \/>        <span style=\"color: #d0d0d0;\">}<\/span><br \/>    <span style=\"color: #d0d0d0;\">}<\/span><br \/><span style=\"color: #d0d0d0;\">}<\/span><br \/><\/pre>\n<\/div>\n<div>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430:<\/p>\n<p><b><span style=\"color: #e69138;\">B*.txt<\/span><\/b><br \/><b><span style=\"color: #e69138;\">*.dll<\/span><\/b><br \/><b><span style=\"color: #e69138;\">Del*f.doc<\/span><\/b><\/p>\n<p>\u0438 \u0442. \u043f.<\/p><\/div>\n<\/div>\n<div>http:\/\/geckich.blogspot.com\/<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043c\u0430\u0441\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u0451 \u0447\u0435\u0440\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \ud83d\ude42 \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0441\u044f\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c &#8211; \u0430\u0440\u0445\u0438\u0432 \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438 \u0431\u044b\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u043e\u043c&#8230; \u0422. \u0435. \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u044f New-Item \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b, \u043d\u043e &hellip; <a href=\"https:\/\/geckich.space\/?p=302\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Windows 2003 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PowerShell<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,9],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-programming","category-windows"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302"}],"version-history":[{"count":0,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions"}],"wp:attachment":[{"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}