May 6th, 2019 | Tags:

Get all user with selected info and Dl group By powershell.

Get-ADUser -Filter * -Properties * -SearchBase "OU=CPG,DC=ISNET,DC=CORP,DC=ORG" | Select-Object givenName,sn,displayName,physicalDeliveryOfficeName,streetAddress,l,st,postalCode,co,title,department,company,homeMDB,@{n=’MemberOf’; e= { ( $_.memberof | % { (Get-ADObject $_).Name }) -join “,” }} | export-csv -path c:\temp\allusers.scv
April 30th, 2019 | Tags:

Remove user account from local Administrators group :

The following powershell commands remove the given AD user account from local Admins group.

$user = "DomainName/user1";
$group = "Administrators";
$groupObj =[ADSI]"WinNT://./$group,group" 
$userObj = [ADSI]"WinNT://$user,user"
$groupObj.Remove($userObj.Path)

If you want to remove non-domain local user account, you need to just pass the username as shown below:

$user = "ComputerName/user1";

Remove multiple users from local Administrators group :

Use the below PowerShell script to remove set of Active Directory user accounts from local Admins group. First create the text file users.txt which includes one user name in each line.

$group = "Administrators";
$groupObj =[ADSI]"WinNT://./$group,group" 
ForEach ($user in (Get-Content "C:\users.txt"))
{
   $userObj = [ADSI]"WinNT://$user,user"
   $groupObj.Remove($userObj.Path)
}

Remove user from local Admins group on Remote computer :

We need to provide the remote computer name to remove local Administrators group member on a remote computer.

$computer = "GEN8";
$domainUser = "DomainName/user1";
$groupObj =[ADSI]"WinNT://$computer/Administrators,group" 
$userObj = [ADSI]"WinNT://$domainUser,user"
$groupObj.Remove($userObj.Path)
April 30th, 2019 | Tags:

Add a user account to the local Administrators group :

The following powershell commands add the given user account to local Admin group.

$user = "ComputerName/user1";
$group = "Administrators";
$groupObj =[ADSI]"WinNT://./$group,group" 
$userObj = [ADSI]"WinNT://$user,user"
$groupObj.Add($userObj.Path)

Add a AD domain user account to the local Admin group :

We can use the above same commands to add domain user account by just passing the domain user.

$domainUser = "DomainName/user1";
$group = "Administrators";
$groupObj =[ADSI]"WinNT://./$group,group" 
$userObj = [ADSI]"WinNT://$domainUser,user"
$groupObj.Add($userObj.Path)

Add a domain user account to the local Administrators group on a Remote computer:

We need to just pass the remote machine name to add an Active Directory user to the local Administrators group on a remote Windows computer with PowerShell.

$computer = "GEN8";
$domainUser = "DomainName/user1";
$group = "Administrators";
$groupObj =[ADSI]"WinNT://$computer/$group,group" 
$userObj = [ADSI]"WinNT://$domainUser,user"
$groupObj.Add($userObj.Path)
April 30th, 2019 | Tags:

Get Computer List from DC

Get-ADComputer -Filter * -SearchBase "CN=Workstations, DC=contoso, DC=com"

删除输入文件的双引号

... | ConvertTo-Csv -NoTypeInformation | % { $_ -replace '"' } | Out-File $csv

如果要删除首行

... | select -Skip 1 | Out-File $csv

完整实例

Get-ADComputer -Filter * -SearchBase "OU=cpg computers,dc=isnet,DC=corp,DC=org" -Properties * |Select name| ConvertTo-Csv -NoTypeInformation | % { $_ -replace '"' } | select -Skip 1 |Out-File C:\Script\PingEnduser\RemoteComputers.txt

PING IP and Send email

############ping tEST############### 
Get-Content C:\Script\PingEnduser\RemoteComputers.txt | ForEach-Object{
$pingstatus = ""
IF (Test-Connection -BufferSize 32 -Count 1 -ComputerName $_ -Quiet) {
        $pingstatus = "Online"
} Else {
        $pingstatus = "Offline"
}

New-Object -TypeName PSObject -Property @{
      Computer = $_
      Status = $pingstatus }
} | Export-Csv C:\Script\PingEnduser\PingStatus_$(get-date -f dd_MMM).csv -NoTypeInformation -Encoding UTF8

###########Email Sending Part######## 

###########Define Variables######## 
 
$fromaddress = "[email protected]" 
$toaddress = "[email protected]" 
$CCaddress = "[email protected]"
#$bccaddress = "[email protected]" 
#$CCaddress = "[email protected]" 
$Subject = "Offline check for Enduser" 
$body = "PING Test for all CPG laptop and Desktop after office hour."
#$body = get-content .\content.htm 
$attachment = "C:\Script\PingEnduser\PingStatus_$(get-date -f dd_MMM).csv" 
$smtpserver = "[email protected]" 
 
#################################### 
 
$message = new-object System.Net.Mail.MailMessage 
$message.From = $fromaddress 
$message.To.Add($toaddress)
$message.CC.Add($CCaddress) 
#$message.Bcc.Add($bccaddress) 
$message.IsBodyHtml = $True 
$message.Subject = $Subject 
$attach = new-object Net.Mail.Attachment($attachment)
$message.Attachments.Add($attach)
$message.body = $body 
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.Send($message)
 
#################################################################################
April 12th, 2019 | Tags:

因为在看相关资料,所以看到该篇不错的文章,所以转载过来。文章原址 Read more…

April 11th, 2019 | Tags:

Easy way is

Copy-Item "C:\Test_CopyItem" -Destination "\\DC01\C$" -Recurse

Advanced Version

$source='\\server1\folder'
$destination='\\PC1\c$\temp\folder'
Copy-Item -Recurse -Filter *.* -path $source -destination $destination -Force
December 24th, 2018 | Tags:

Open a command prompt and type the following

vssadmin list shadowstorage

The below will be displayed.

C:\Users\User>vssadmin list shadowstorage

Shadow Copy Storage association

For volume: (D:)\\?\Volume{ }\

Shadow Copy Storage volume: (D:)\\?\Volume{}\

Used Shadow Copy Storage space: 58.9 GB (3%)

Allocated Shadow Copy Storage space: 61.7 GB (4%)

Maximum Shadow Copy Storage space: 100 GB (6%)

The following command limits the size that VSS can use.

vssadmin resize shadowstorage /for=C: /on=C: /maxsize=50GB
December 23rd, 2018 | Tags:
December 10th, 2018 | Tags:

通过GPO批量更新域控用户IE设定。
修改object路径:

[User Configuration] / [Policies] / [Administrative Templates] / [Windows Components] / [Internet Explorer] / [Internet Control Panel] / [Security Page] / [Site to Zone Assignment List]

编辑并且Enable这一选项;选择Show;添加网址并且设置Value;

在设置网站列表时需要注意的事项:

※设定 Value 时的注意事项
Internet Explorer 有四种不同的安全级别,分别为1 ~ 4
1. 内部网络(Intranet zone)
2. 信任的网站(Trusted Sites zone)
3. 外部网络(Internet zone)
4. 限制的网站(Restricted Sites zone)

January 29th, 2018 | Tags:

免费转换工具
NAME:5nineEasyConverter