powershell 该脚本生成100个随机字符串。注释部分启用所有字母和数字。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 该脚本生成100个随机字符串。注释部分启用所有字母和数字。相关的知识,希望对你有一定的参考价值。

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

    $webUrl = "http://spsvde001/Greater5KSite"
    $listName = "Greater5K"
    # Open web and library
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]
    
    $i = 0
for($i -eq 0;$i -lt 6000;$i++){
    $Private:OFS = ""
    $PasswordLength = 5
    $InclChars = ‘abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789’
    $RandomChar = 1..$PasswordLength | ForEach-Object { Get-Random -Maximum $InclChars.length }
    $RandomPassowrdChar = [String]$InclChars[$RandomChar]
    
    
    $InclNums = "123456789"
    $RandomNums = 1..$PasswordLength | ForEach-Object { Get-Random -Maximum $InclNums.length }
    $RandomPassowrd = [String]$InclNums[$RandomNums]

    #$ItemTitle = $RandomPassowrd

    $newItem = $list.AddItem()
    $newItem["Title"] = $RandomPassowrdChar
    $newItem["NumberField"] = $RandomPassowrd
    $newItem.Update()
    write-host "****************************************"
    write-host "Item created"
}
#Dispose web
$web.Dispose()
#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

    $webUrl = "http://spsvde001/twf"
    $listName = "Test Number Conv"
    # Open web and library
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]
    
    $i = 0
for($i -eq 0;$i -lt 100;$i++){
    $Private:OFS = ""
    $PasswordLength = 5
    ##$InclChars = ‘abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789’
    $InclChars = "123456789"
    $RandomNums = 1..$PasswordLength | ForEach-Object { Get-Random -Maximum $InclChars.length }
    $RandomPassowrd = [String]$InclChars[$RandomNums]

    $ItemTitle = $RandomPassowrd

    $newItem = $list.AddItem()
    $newItem["TestNum"] = $ItemTitle
    $newItem.Update()
    write-host "****************************************"
    write-host "Item created"
}
#Dispose web
$web.Dispose()
#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
 
# Script settings
$webUrl = "http://spsvde001/twf"
$listName = "Test Capitalization"

$ItemTitle = "EC DECLARATION OF CONFORMITY"

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

$newItem = $list.AddItem()
$newItem["Title"] = $ItemTitle
$newItem.Update()
write-host "****************************************"
write-host "Item created"
 
#Dispose web
$web.Dispose()

以上是关于powershell 该脚本生成100个随机字符串。注释部分启用所有字母和数字。的主要内容,如果未能解决你的问题,请参考以下文章

随机生成【1,100】之间的10个整数存放在数组中。

shell生成100个6位随机数

Jmeter-函数生成参数

我想用JavaScript生成1到100之间的100个不能重复的随机数,不需要排序,只生成100个不

php生成随机数字,范围1-100,每次生成一个数字,可以重复

java 编写一C程序,随机生成20个1 ~ 100的随机整数......