小编use*_*554的帖子

Powershell附加CSV

我正在尝试附加CSV文件.这是我正在使用的线条.遗憾的是,我无法为export-csv找到附加选项.任何想法都有助于实现这一目标.

Get-ADGroupMember "Domain Admins" | select name, samaccountname | Export-Csv c:\bin\DomainAdmins.csv

$admins = Import-Csv C:\bin\DomainAdmins.csv

foreach ($i in $admins) {Get-ADUser $i.samaccountname -properties * | select name, lastlogondate | Export-Csv c:\bin\dalogon.csv}
Run Code Online (Sandbox Code Playgroud)

谢谢你,埃里克

powershell

6
推荐指数
2
解决办法
3万
查看次数

找不到“op_Subtraction”的重载和参数计数:“2”

我正在尝试编写一个 Powershell 脚本来识别 90 天未登录的用户,但我不断收到此错误消息:

找不到“op_Subtraction”的重载和参数计数:“2”。起初我认为这是变量类型不匹配,但查看减法变量看起来不错。

PS C:\> $today.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     DateTime                                 System.ValueType

PS C:\> $users[198].LastLogonDate.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     DateTime                                 System.ValueType
Run Code Online (Sandbox Code Playgroud)
$today = Get-Date
$days = 90
$users = Get-ADUser -Properties * -Filter *
foreach ($i in $users) 
{
    $difference = $today - $i.LastLogonDate
    #Write-Host $i.Name + $difference.Days
    if ($difference.Days -ge $days){Write-Host $i.name " hasn't logged on in 90 days"}
    elseif ($i.LastLogonDate -eq $null) {Write-Host …
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
2万
查看次数

Python拆分、替换

我正在写一份便条,但遇到了障碍。可能有一种更有效的方法来做到这一点,但我对 Python 相当陌生。我正在尝试创建用户生成的 IP 地址列表。我正在使用 print 来查看生成的值是否正确。当我运行此代码时,打印 ip_start 具有相同的值并且未更新。我确信这是一个相当简单的修复,但我有一个主要的脑锁。

ip_start = raw_input('Please provide the starting IP address for your scan --> ')
start_list = ip_start.split(".")
ip_end = raw_input('Please provide the ending IP address for your scan --> ')
end_list = ip_end.split(".")
top = int(start_list[3])
bot = int(end_list[3])
octet_range = range(top,bot)
print octet_range
for i in octet_range:
    print i
    print "This the top:" + str(top)
    ip_start.replace(str(top),str(i))
    print ip_start
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
2万
查看次数

Python - 从用户输入生成IP地址列表

我正在尝试创建一个脚本,该脚本根据开始和结束IP范围的用户输入生成IP地址列表.例如,他们可以输入192.168.1.25和192.168.1.50.然后该列表将被输入scapy以测试开放端口.我想我已经生成了列表,但是我仍然坚持将各个IP输出到我的其余代码中.我想我正在尝试使用整个列表与列表中的项目.如果有更好的方法,这很好.我这样做主要是为了提高我对Python的理解.

谢谢!

from scapy.all import *

ip_start = raw_input('Please provide the starting IP address for your scan --> ')
start_list = ip_start.split(".")
ip_end = raw_input('Please provide the ending IP address for your scan --> ')
end_list = ip_end.split(".")
top = int(start_list[3])
bot = int(end_list[3])
octet_range = range(top,bot)
#print octet_range
for i in octet_range:
    #new_ip_start = ip_start.replace(str(top),str(i))

    start_list[3] = i
    #print top
    #print i
    print type(start_list)    
    src_port = RandShort()
    dst_port = 80
    scan = sr1(IP(dst=str(start_list))/TCP(sport=src_port,dport=dst_port,flags="S"),timeout=10)
Run Code Online (Sandbox Code Playgroud)

python

2
推荐指数
2
解决办法
7481
查看次数

学习Python线程模块

我想了解更多有关线程模块的信息.我想出了一个快速的脚本,但是当我运行它时出现错误.文档显示格式为:

thread.start_new_thread ( function, args[, kwargs] )
Run Code Online (Sandbox Code Playgroud)

我的方法只有一个参数.

#!/usr/bin/python

import ftplib
import thread

sites = ["ftp.openbsd.org","ftp.ucsb.edu","ubuntu.osuosl.org"]

def ftpconnect(target):
        ftp = ftplib.FTP(target)
        ftp.login()
        print "File list from: %s" % target
        files = ftp.dir()
        print files

for i in sites:
    thread.start_new_thread(ftpconnect(i))
Run Code Online (Sandbox Code Playgroud)

我看到的错误发生在for循环的一次迭代之后:

回溯(最近一次调用最后一次):文件"./ftpthread.py",第16行,在thread.start_new_thread(ftpconnect(i)中)TypeError:start_new_thread预期至少有2个参数,得到1

对此学习过程的任何建议将不胜感激.我也研究过使用线程,但我无法导入线程,因为它显然没有安装,我还没有找到安装该模块的任何文档.

谢谢!

尝试在我的Mac上导入线程时出现错误:

>>> import threading
# threading.pyc matches threading.py
import threading # precompiled from threading.pyc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "threading.py", line 7, in <module>
    class WorkerThread(threading.Thread) :
AttributeError: 'module' object …
Run Code Online (Sandbox Code Playgroud)

python multithreading

1
推荐指数
1
解决办法
5287
查看次数

标签 统计

python ×3

powershell ×2

multithreading ×1