Can I get registry key last write times (RegQueryKeyInfo/lpftLastWriteTime) with PowerShell? Is there something more detailed that Get-ChildItem which will give them automatically? Thanks.
- Vince
Can I get registry key last write times (RegQueryKeyInfo/lpftLastWriteTime) with PowerShell? Is there something more detailed that Get-ChildItem which will give them automatically? Thanks.
- Vince
Hey guy,
Have a quick question to see if I can get some feedback.
I am needing to create an 'object' that has multiple attributes associated with it. Much like a HashTable, but instead of it only having a 'Name' and 'Value' that can be accessed, (I am probally not using the right wording but you can get an idea of what I need for my end result from my example) I need to create something in powershell that is an object that can have multiple items to access such as
$object1 = ("headerItem1", "headerItem2", "headerItem3", "headerItem4")
$object1.add ("testrow1a", "testrow1b", "testrow1c", "testrow1d")
$object1.add ("testrow2a", "testrow2b", "testrow2c", "testrow2d")
And I would like to be able to access it like you would any other PowerShell object - such as
$object1.HeaderItem1
and it would return
testrow1a
testrow2a
Let me know what you think, or if anyone can offer assistance. [I know I can do it through creating a CSV, but I don't want to do it through that, I would like to create an Object, and then access it from there.)
Hello, at this point I need to accomplish a basic task in Powershell:
Since I have multiple network adapters configured, I need to pick the desired network adapter I want to capture packets from/to.
THen to get started, I write the Powershell script which will display the respective packet output.
Can you someone point me a to a script which can let me do that or kindly give me an example?
Thanks,
M
trying to search users but receive error (Operator '+' cannot be applied to operand of type 'string')
public
string searchuser(){
try
{
DirectoryEntry entry =newDirectoryEntry("LDAP://"+ GetSystemDomain());
DirectorySearcher Dsearch =newDirectorySearcher(entry);
Dsearch.Filter =
"(&((&(objectCategory=Person)(objectClass=User)))(sn="+ txtsearch.Text + *+"))";
using (StringWriter sw = newStringWriter())
{
foreach (SearchResult sResultSet in Dsearch.FindAll())
{
sw.WriteLine(
"{0}", (GetProperty(sResultSet,"samaccountname"+"Name")));
}
return sw.ToString();
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
returnnull;
}
Support@Mytechnet.me
I need to generate some reports with charts. On all my machines (including a DC) with .NET 4 except one, I could simply load the DataVisualization assembly with:
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.DataVisualization")
On one Windows Server 2008 R2, the above statement returns $null. Is there anything I need to do to enable this particular assembly?
Thanks.
I am trying to read a xml data into datagridview and want to sort the first column in ASC order.
$ds=New-ObjectSystem.Data.Dataset
$dataGridView=New-ObjectSystem.Windows.Forms.DataGridview
$ConfigXMLFile="D:\test.xml"
$ds.ReadXml($ConfigXMLFile)
$dataGridView.DataSource=$ds.Tables[0].DefaultView
$dataGridView.Sort($dataGridView.Columns[0],'ASC')
Output of the above script is as follows
sequence Name
1 SSS
10 YYYY
2 aaaa
3 bbbb
But I want to sort the above result as below
sequence Name
1 SSS
2 aaaa
3 bbbb
10 YYYY
Thanks in advance.
Hi,
Can anyone tell me how to access systems and security in powershell and check settings using powershell. How to access mount points also using powershell on server ?
Hi i was wondering if anyone can help i have 2 text file i want to compare.
one will be the final one and one is temporary
the temp file will have new information in it and i want to write these changes to the final file but i need to insert them in the same place as they are in the temp file so for example if the final file has
1
2
3
6
7
and the temp file has
1
2
3
4
6
7
to insert the number 4 in at line 4 so it mirrors the temp file basically the final file my be edited out side of the script so this information needs to remain intact and the new lines added in the correct location in the file also there may be more than one change in the temp file any help would be great
Hi
Ive created a Gui with powershell and som list boxes.
What i want to do is, when i select (mouse click on it) an object in my list, i want to show infomation about that object. But i cant find the code for click-select-action.
Here's a pic, ive selected https://intranett,
I have a textfield under where i want to display its size in MB.
all help with be greatly appricated!
br
Bjorn
When using get-winevent the Message field is almost always empty. This is where I assumed the description of the error would be.
How do I get the error description (basically the text that is shown in the General Tab of the Event Viewer on Windows Server 2008)?
How to add items in listbox and columns
public string searchuser()
{
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + GetSystemDomain());
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = "(&((&(objectCategory=Person)(objectClass=User)))(samaccountname=" + txtsearch.Text + "))";
using (StringWriter sw = new StringWriter())
{
foreach (SearchResult sResultSet in Dsearch.FindAll())
{
listBox1.Items.Add(sw.WriteLine("{0}", (GetProperty(sResultSet, "Name", "Name"))));
}
return sw.ToString();
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
return null;
}
Support@Mytechnet.me
how can I get the duration of a mp3 file in seconds ?
In need in seconds because I use start-sleep and this cmdlet use -seconds parameter ..
I found a module that "read" the information about files, audio or video but it return in minutes "00:03:51.6540000"
Can I convert to seconds ?
sorry for my english :D
Hi Guys,
I want to get a list of all files (excluding directories) from a disk. I need them as paths, and I need them encased in quotes, as the programs I will be feeding the output into is quite picky about syntax.
Say I have a directory tree like:
D:.
├───1
│ │ 1.txt
│ │ 2.txt
│ │
│ └───3
│ 1.txt
│ 2.txt
│
└───2
1.txt
2.txt
I've fiddled and looked about, but I cant find anything that gives me quite what I want. I got to this command: gci -r | where-object {$_.mode -lt "d"} | gci -n, which gives the output:
1.txt
2.txt
1.txt
2.txt
1.txt
2.txt
Unfortunately, I need
"D:\1\1.txt"
"D:\1\2.txt"
"D:\1\3\1.txt"
etc.
I'm fairly new to powershell, so I'm sorry if I've missed a blindingly simple way to do this.
Thanks in advance,
Mini
Hi there,
I have the code below that I can point to my local Active Directory Certificate Authority and it will pull back expiring certificates, based on a set number of days.How do i run this script? I have copied the script and created a cascript.ps1 file and changed the $CAlocation="CAServer\Some Root CA" to my CA server and name and $duedays=365 though when I run it in powershell ./cascript.ps1 it doesn't output anything.... any help will be greatly appreciated. Thanks
function get-ExpiringCerts ($duedays=60,$CAlocation="CAServer\Some Root CA") { $certs = @() $now = get-Date; $expirationdate = $now.AddDays($duedays) $CaView = New-Object -Com CertificateAuthority.View.1 [void]$CaView.OpenConnection($CAlocation) $CaView.SetResultColumnCount(5) $index0 = $CaView.GetColumnIndex($false, "Issued Common Name") $index1 = $CaView.GetColumnIndex($false, "Certificate Expiration Date") $index2 = $CaView.GetColumnIndex($false, "Issued Email Address") $index3 = $CaView.GetColumnIndex($false, "Certificate Template") $index4 = $CaView.GetColumnIndex($false, "Request Disposition") $index0, $index1, $index2, $index3, $index4 | %{$CAView.SetResultColumn($_) } # CVR_SORT_NONE 0 # CVR_SEEK_EQ 1 # CVR_SEEK_LT 2 # CVR_SEEK_GT 16 $index1 = $CaView.GetColumnIndex($false, "Certificate Expiration Date") $CAView.SetRestriction($index1,16,0,$now) $CAView.SetRestriction($index1,2,0,$expirationdate) # brief disposition code explanation: # 9 - pending for approval # 15 - CA certificate renewal # 16 - CA certificate chain # 20 - issued certificates # 21 - revoked certificates # all other - failed requests $CAView.SetRestriction($index4,1,0,20) $RowObj= $CAView.OpenView() while ($Rowobj.Next() -ne -1){ $Cert = New-Object PsObject $ColObj = $RowObj.EnumCertViewColumn() [void]$ColObj.Next() do { $current = $ColObj.GetName() $Cert | Add-Member -MemberType NoteProperty $($ColObj.GetDisplayName()) -Value $($ColObj.GetValue(1)) -Force } until ($ColObj.Next() -eq -1) Clear-Variable ColObj $datediff = New-TimeSpan -Start ($now) -End ($cert."Certificate Expiration Date")"Certificate " + $cert."Issued Common Name" + " will expire in " + $dateDiff.Days + " days at " + $cert."Certificate Expiration Date" #"Send email to : " + $cert."Issued Email Address""------------------------" } $RowObj.Reset() $CaView = $null [GC]::Collect() } get-ExpiringCerts -duedays 365 -CAlocation "CAServer\Some Root CA"
Hi all,
Basically I am following the guide below, I have re-installed exchange etc etc now I am trying to run the script to re-install the sbs2008 roles
exchangemaster.wordpress.com/2010/01/03/how-to-fully-re-install-exchange-on-sbs-2008-3/
The main problem I am having is with
New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000″ -VirtualDirectoryType “Exadmin” -ExternalAuthenticationMethods Fba
New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000″ -VirtualDirectoryType “Mailboxes” -ExternalAuthenticationMethods Fba
New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000″ -VirtualDirectoryType “Exchweb” -ExternalAuthenticationMethods Fba
New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000″ -VirtualDirectoryType “PublicFolders” -ExternalAuthenticationMethods Fba
When this is run it results in error:
Incomplete string token. At C:\Windows\System32\sbsALLrolereinstall.ps1:57 char:117 + New-OWAVirtualDirectory -WebsiteName "SBS Web Applications" -OwaVersion "Exchange2003or2000" -VirtualDirectoryType "M<<<< ailboxes" -ExternalAuthenticationMethods Fba
Any ideas how to fix this?
cheers
Hi there,
i got two trusted domains in different forests and want to retrieve the members oft some groups which contain members of both domains. Get-AdGroupmeber fails with an ADException Error. Groups with members from only their own domain work fine.
The domainmode is windows2003 which both have Windows 2008 R2 domaincontrollers with Active Directory Webservices running.
ADWS running on both Win2008R2 DC's which are both GC! The Problem Members show in the ADUC with their names. So the UC resolves the Names correct. The error was german i have translated it:Get-ADGroupMember : Operation successfully finished
At C:\Users\adm_XXXX\AppData\Local\Temp\4fc3e5dc-e943-446a-ae65-e7178f9e6076.ps1:4 Sign:18
+ Get-ADGroupMember <<<< -Identity "XXXXXX,OU=XXXXXXXXX,OU=XXXXXXXXX,DC=XXXXXXXXX,DC=XX"
+ CategoryInfo : NotSpecified: (CN=XXXXXXXXXXX,OU=XXXXXXXXXXXXXXXX,DC=XX:ADGroup) [Get-ADGroupMember], ADException
+ FullyQualifiedErrorId : Operation successfully finished,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember
Any advice how to fix this?
Sorry for my bad english!
Thank you!
I have a couple of status check functions which report on long-running functions (e.g. mailbox exports) which are foreach-ing against a list of user names.
The long running functions all seem to run concurrently. However, I would like the status checks to also execute simultaneously. None of the other functions send out-put to the console.
What is an elegant way of accomplishing this feat?
function MailboxExportRequestStatus { $statReport = Get-MailboxExportRequestStatistics -Identity $user_name\mailboxExport -IncludeReport $i = 0 while ( $statReport.status -eq "Queued" ) { $statReport = Get-MailboxExportRequestStatistics -Identity $user_name\mailboxExport -IncludeReport Write-Host "`t`t`tExport request for" $user_name "has been in queue for" ($i * 15) "seconds" sleep -Seconds 15 $i++ } while ( $statReport.status -eq "InProgress" ) { $statReport = Get-MailboxExportRequestStatistics -Identity $user_name\mailboxExport -IncludeReport Write-Host "`t`tExport request for" $user_name "is in progress. It is" $statReport.PercentComplete"% complete" sleep -Seconds 15 } while ( $statReport.status -eq "Completed" ) { $statReport = Get-MailboxExportRequestStatistics -Identity $user_name\mailboxExport -IncludeReport Write-Host "`t`t`t`tCompleted! The mailbox esport request for" $user_name "is now"$statReport.PercentComplete"percent complete" sleep -Seconds 2 } Get-MailboxExportRequestStatistics -Identity $user_name\mailboxExport -IncludeReport }
foreach ( $user_name in $user_names)
{
spam
eggs
MailboxExportRequestStatus
foo
bar
}
Hi
I'm looking to learn Powershell to automate some repetitive task we do in our Desktop support group. For example, could a script be written to prompt us for a user ID which we would then supply or have it search for one based on what we type in. The script would then disable that user ID and move it to an OU that we specify, the OU would change though depending on the month. Could part of that script also move their machine account to that same OU?
Thanks
Joshua
When run the command set-qaduser , it pops the error , I am not sure if this is permission restriction , could advise a script to verify if this is really permission issue ? thanks
set-qaduser : access is denied
categoryinfo : notspecified : [ set-QADUser ] , UnauthorizedAccessException