Articles of shell

Powershell脚本自动化邮箱到PST

我有一个正在工作的脚本,但我不是一个高级程序员。 请有人修改我的脚本,因为我想? 1)邮箱应该从特定的服务器“ServerX”中导出。 此脚本现在扫描所有交换数据库。 2)只是为了validation什么时候运行这个脚本,它应该准确地把上个月的备份到所需的共享位置。 说如果在2015年12月9日运行这个脚本,它应该从2015年11月9日到12月9日进行备份。 3)脚本的下半部分在检查导出请求的地方没有工作。 有人可以build议它需要什么样的修改。 $Export = Get-Mailbox $endDate = Get-Date "00:00:00" $startDate = $endDate.AddDays(-30) $month = "{0:D2}" -f [int]$startDate.Month $year = "{0:D4}" -f [int]$startDate.Year Write-Host -NoNewline "Exporting items between $startDate and $endDate…" $Export|%{$_|New-MailboxExportRequest -ContentFilter {(Received -ge $startDate) -and (Received -lt $endDate)} -FilePath "\\FileServer\EmailBackups\ExportTest\Test\$($_.alias).pst"} Write-Host "Done." **After this script gives error. But […]

PowerShell:使用目录层次结构填充TreeView

所以我试图用GUIinput编写一个PowerShell脚本; 想法是最终用户看到文件系统的一个嵌套的TreeView。 他们打勾了一些文件夹,打了一个button,…发生了魔法。 我有挂载点(不知道C发生了什么),问题是我似乎无法弄清楚/find如何枚举和添加为嵌套节点。 我的search结果似乎都指向了C#,C ++等例子; 不是有帮助的。 想法? 这就是我得到的 这是我想要的(但不断深入) 所以这是我的代码到目前为止 $objDriveLetters = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk" $form = New-Object System.Windows.Forms.Form $treeView = New-Object System.Windows.Forms.TreeView $treeView.Dock = 'Fill' $treeView.CheckBoxes = $true foreach ($iDrive in $objDriveLetters) { $DriveRoot = Get-Item $iDrive.DeviceID #$FolderRoot = Get-ChildItem -Path $iDrive.DeviceID $FolderRoot = Get-Item -Path $iDrive.DeviceID $treeView.Nodes.Add($FolderRoot.FullName, $FolderRoot.FullName) } […]

列出Get-Eventlog cmdlet的参数

我需要使用Get-Eventlog cmdlet来显示日志名称和保留期限。 我用过Get-Eventlog -list | 格式表日志,保留 但它只显示日志,“保留”列是空的。 保留期的参数是什么,所以这些数字将与日志名称一起显示? 谢谢

如何在Archlinux服务器上创buildchroot'ed SFTP访问?

我已经按照ArchWiki和GeekStuff上的这个说明设置了一个用户,他只能通过SFTP(SSH)访问服务器,但是在他家目录的chroot环境中没有Shell( /bin/false )。 没有什么更特别的,但它根本无法正常工作,当我尝试login时,我不断得到access denied消息。这是我迄今为止所尝试的: SFTP用户和组 用户(在这里: user )是组sftp成员。 主目录是/srv/sftp/user 。 Shell通过/bin/false被禁用 用户input: 0 ✓ root@host ~ $ grep -i user /etc/passwd user:x:1002:1000::/srv/sftp/user:/bin/false 小组条目: 0 ✓ root@host ~ $ grep -i sftp /etc/group sftp:x:1000:user 用户组: 0 ✓ root@host ~ $ groups user users sftp 主目录configuration 主目录和上面的所有目录都由root拥有: 0 ✓ root@host ~ $ ls -lsha /srv total […]

错误,而玩耍的剧本

我只是安装在aws服务器上,然后创build一个剧本运行相同,但在运行时,我得到如下错误: ERROR! 'copy' is not a valid attribute for a Play The error appears to have been in '/root/amritha/pega-cloud-infrastructure/ansible/roles/datadog-pegalogs-apptier/tasks/main.yml': line 3, column 3, but may be elsewhere in the file depending on the exact syntax problem. 违规行似乎是: – name: copy the pattern_search.txt file which has patterns to be grepped ^ here 而我的剧本如下: – name: copy […]

elinks | 表单提交后转储

我试图find一种方式,转储页面的内容,当表单由elinks提交。 /usr/bin/elinks -auto-submit 1 -eval 'set document.browse.forms.confirm_submit = 0' $LINK 如果使用了-dump ,则在提交之前将导出页面的内容。 同样,当我们使用>出口运营商来结束文件。 我不期待curl解决scheme。 谢谢,

使用CRON但不使用SHELL的OOM

当我通过shell启动一个java程序时,一切正常。 但是,如果我用同一个命令和同一个用户通过CRON启动相同的程序,我会在几秒钟后得到一个java.lang.OutOfMemoryError。 另外,只要我不杀死被阻塞的java程序,CRON就不能做任何事情。 无论哪个cronjob应该启动,它总是以syslog中的“(CRON)错误(无法分叉)”结束。 杀死Java程序后,所有新的cronjobs再次正常工作。 java程序创build了许multithreading(启动时为1500,之后更多),而且当由crontab启动时,它始终在创build475个线程后开始挂起。 所以也许它更像“OutOfThreads”甚至OutOfMemorylogging。 为了testing的目的,我把初始线程的数目减less到了450,并且这个设置在一些分钟内工作正常(直到更多的线程被创build)。 然而,我真的需要这些1500+线程,我不知道为什么这是不可能的,当java程序已经由crontab启动。 如前所述,只要我通过shell启动程序,而不是通过crontab启动程序,一切正常。 这个问题只发生在Ubuntu 16.04上,所有旧版本都运行得很好。 这是一个错误还是一个新的安全function? 我没有find任何有关这个问题的信息,所以我希望任何人都可以帮忙。

如何使整个networking更快的PowerShell文件search

我试图searchADnetworking中所有机器上的所有驱动器,我的方法效率不高。 基本上,我想出了这样一个脚本,它是这样做的: 从AD获取所有计算机。 检查是否有WMI连接,logging机器,以便我可以照看。 获取计算机上的所有物理驱动器。 search远程共享上的文件 $computers = Get-ADComputer -filter * | Select -Exp Name $computers.Count $i = 0 foreach ($computer in $computers) { $i++ Write-Host "Checking Computer Number " $i " with the hostname " $computer if (Test-Connection $computer -Quiet ) { $drives = get-wmiobject -computer $computer win32_logicaldisk -filter "drivetype=3" | select -Exp DeviceID […]

pfSenseshell:应用configuration修改而不重新启动

我目前正在尝试使用pfSsh.php shell来编辑正在运行的pfSense的configuration。 通过使用pfSsh.phpshell,我可以修改configuration,但一旦写入,它就不会应用于系统。 有没有办法强制configuration重新加载而不重新启动整个系统? pfSense shell: $newIp['mode'] = 'ipalias'; pfSense shell: $newIp['interface'] = 'wan'; pfSense shell: $newIp['descr'] = 'vip1'; pfSense shell: $newIp['type'] = 'single'; pfSense shell: $newIp['subnet_bits'] = 24; pfSense shell: $newIp['subnet'] = '192.168.0.241'; pfSense shell: $config['virtualip']['vip'][] = $newIp; pfSense shell: parse_config(true); pfSense shell: write_config(); pfSense shell: exec; 如果我打印configuration,我可以看到添加了贵宾: [virtualip] => Array ( [vip] => […]

Powershell脚本检查Windows事件日志中的重要消息

我有一个PowerShell脚本检查应用程序和系统Windows事件日志中的错误。 有没有也让它检查关键的消息? 在Windows事件日志中。 以下是一个示例脚本: Set-Variable -Name EventAgeDays -Value 1 #we will take events for the latest 7 days Set-Variable -Name CompArr -Value @("Server 1") # replace it with your server names Set-Variable -Name LogNames -Value @("Application", "System") # Checking app and system logs Set-Variable -Name EventTypes -Value @("Error") # Loading only Errors and Warnings Set-Variable […]